form control error on form submission in laravel app - laravel

on form submission, for some fields form-control error is working on one text area it is not working, this is description area + in control error i want to include that submitter should fill min 350 words or more. here is exact from blade template
control error is working on this:
<div class="form-row mb-3">
<div class="col-md-4">
<label for="item_title" class="text-black">{{ __('backend.item.title') }}</label>
<input id="item_title" type="text" class="form-control #error('item_title') is-invalid #enderror" name="item_title" value="{{ old('item_title') ? old('item_title') : $item->item_title }}">
#error('item_title')
<span class="invalid-tooltip">
<strong>{{ $message }}</strong>
</span>
#enderror
control error is not working on this fill
<div class="form-row mb-3">
<div class="col-md-12">
<label for="item_description" class="text-black">{{ __('backend.item.description') }}</label>
<textarea class="form-control #error('item_description') is-invalid #enderror" id="item_description" rows="5" name="item_description">{{ old('item_description') ? old('item_description') : $item->item_description }}</textarea>
#error('item_description')
<span class="invalid-tooltip">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
i applied the control but its not working

Related

Laravel 8 Image source not readable, on Intervention Image resize (Shared hosting)

I'm using Laravel 8. I was working on my machine (locally), after deploying it on the Shared hosting (my case Bluehost), I have moved the project to the root of my hosting, And I created a subdomain to my Laravel project, and I moved the public folders file to the subdomain folder.
I have executed the php artisan storage:link, everything works fine, even the images are uploaded, but the problem is when I use the Intervention Image to resize the image it shows
Intervention\Image\Exception\NotReadableException
Image source not readable
The code:
$imageName = $request['image']->store('uploads/brand', 'public');
Intervention\Image\Facades\Image::make(public_path("storage/{$imageName}"))->fit(1024, 1024)->save();
I have tried some solutions, but no result, the error kept the same
The solutions that I tried:
1- config/filesystems.php
'links' => [
base_path('/public_html/storage') => storage_path('app/public'),
],
2- I tried to specify the public path manually.
3- https://stackoverflow.com/a/39971026/5862126
the error is
Intervention\Image\Exception\NotWritableException
Can't write image data to path (/home4/ctwotec3/laravel_market/public/uploads/4386300.jpg)
Edited 1:
HTML Form code
#extends('layouts.app')
#section('content')
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="container">
<form action="/brand" enctype="multipart/form-data" method="POST">
{{ csrf_field() }}
<div class="card">
<div class="card-header">
<h1 class="text-center">New Brand</h1>
</div>
<div class="card-body">
<div class="col-10 offset-1">
{{-- Name English --}}
<div class="row">
<div class="row mb-3">
<label for="name_en" class="col-md-4 col-form-label text-md-end">Name English</label>
<div class="col-md-6">
<input id="name_en" type="text"
class="form-control #error('name_en') is-invalid #enderror" name="name_en"
value="{{ old('name_en') }}" autocomplete="name_en" autofocus>
#error('name_en')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
</div>
{{-- Name Kurdish --}}
<div class="row">
<div class="row mb-3">
<label for="name_ku" class="col-md-4 col-form-label text-md-end">Name Kurdish</label>
<div class="col-md-6">
<input id="name_ku" type="text"
class="form-control #error('name_ku') is-invalid #enderror" name="name_ku"
value="{{ old('name_ku') }}" autocomplete="name_ku" autofocus>
#error('name_ku')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
</div>
{{-- Name Arabic --}}
<div class="row">
<div class="row mb-3">
<label for="name_ar" class="col-md-4 col-form-label text-md-end">Name Arabic</label>
<div class="col-md-6">
<input id="name_ar" type="text"
class="form-control #error('name_ar') is-invalid #enderror" name="name_ar"
value="{{ old('name_ar') }}" autocomplete="name_ar" autofocus>
#error('name_ar')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
</div>
{{-- Single image --}}
<div class="row">
<div class="row mb-3">
<label for="image"
class="col-md-4 col-form-label text-md-end">{{ __('Item image') }}</label>
<div class="col-md-6">
<input id="chooseFile" type="file" class="form-control" name="image" #error('image')
is-invalid #enderror accept=".jpg,.jpeg,.png">
#error('image')
<strong style="color: red">{{ $message }}</strong>
#enderror
</div>
</div>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-center">
<button class="btn btn-primary mt-3 mb-3 float-end w-75 ">submit</button>
</div>
</form>
</div>
#endsection
Edited 2: here is the path of the uploaded image on the server, that the Intervention Image can't read it
/home4/ctwotec3/laravel_market/public/storage/uploads/brand/r0kBFdXcxCg59WKIwmNsIwq16g30mWs4LZLxWSeT.jpg

How to Get Value From Trumbowyg Textarea on Livewire

I created textarea form element using Livewire, I use Trumbowyg to make WYSIWYG. After sending data trhough submit on livewire, I coundn't get data from textarea, it's null and not passing validation.
Here is my text area form:
<div class="form-group col-md-12">
<label for="content" class="box-title">{{ __('Content') }}</label>
<textarea id="content" name="content" class="form-control form-control-user #error('content') is-invalid #enderror" wire:model.defer="content" required autocomplete="content">
</textarea>
#error('content')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
Is there any solution for these?

How to Handle Laravel error messages in vue?

I know I did something wrong here, but how do you handle error messages of Laravel in vue template?... is there a way of bypassing the #error of the laravel Blade templating
this is the vue component file (fileComponent.vue)
<template>
<div class="row my-2">
<div class="col-md-2 font-weight-bold pt-2">Grade:</div>
<div class="col-md-10">
<select name="grade" class="form-control #error('grade') is-invalid #enderror" v-model="selected_grade" #change="onChange($event)">
<option v-for="grade in grading" :key="grade.id" :value="grade.name">{{grade.name}}</option>
</select>
#error('grade')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
<div class="row my-3" v-if="subjects !== null">
<div class="col-md-3">
<div class="card shadow">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold">Subjects:</h6>
</div>
<div class="card-body">
<div class="custom-control custom-checkbox" v-for="subject in subjects" :key="subject.id">
<input type="checkbox" class="custom-control-input #error('subjects') is-invalid #enderror" name="subjects[]" :id="subject.name" :value="subject.name"/>
<label class="custom-control-label" :for="subject.name">{{subject.name}}</label>
</div>
#error('subjects')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
</div>
</div>
</div>
</div>
</template>
This is Shown on the page instead of error message

Login form in Laravel is giving the error 419 Page Expired

It used to work somoothly, then I added Sociallite and then it some point it broke the default login with email and password.
Now every time I login with username and password I get the error "419 Page Expired" and it's literally diving me crazy because I have tried everything, with no luck.
View login.blade.php:
<form method="POST" action="{{ route('login') }}">
#csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control #error('email') is-invalid #enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control #error('password') is-invalid #enderror" name="password" required autocomplete="current-password">
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Login') }}
</button>
#if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
#endif
</div>
</div>
</form>
Route web.php:
Route::post('login', [
'as' => '',
'uses' => 'Auth\LoginController#login'
]);
I searched the web and found some ppl talking about clearing cash, clearing cookies, checking cash and storage permissions, clearing SESSION_DOMAIN and I did all, but it's still the same.
Please anyone is still facing such issue in Larvel 7?

SQLSTATE[HY000]: General error: 1364 Field 'isAdmin' doesn't have a default value

SQLSTATE[HY000]: General error: 1364 Field 'isAdmin' doesn't have a default value (SQL: insert into users (name, email, password, updated_at, created_at) values (user, user123#gmail.com, $2y$10$hL36LXvdO/0m6PcAtZ1Zvurr5fg6HYX/v9hFTQLPBjYMlWpc3Fkv., 2020-04-18 13:25:15, 2020-04-18 13:25:15))
I can't put data when i click button register
file register.blade.php:
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Register') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('register') }}">
#csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control #error('name') is-invalid #enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
#error('name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control #error('email') is-invalid #enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
#error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control #error('password') is-invalid #enderror" name="password" required autocomplete="new-password">
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Register')}}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
I think you should make your isAdmin field nullable or set default value:
$table->integer('isAdmin')->nullable();
or,
$table->integer('isAdmin')->default(0);
I happens because Because your isAdmin column is not nullable & when you add a new user data, you don't give any value for isAdmin Column...Here you have Two Solution either in your migration or when you create a user then give it's value either 0 or 1..
Or add a new migration where make this column nullable or set it a default value for this..
$table->boolean('isAdmin')->nullable();
Or set a default value
$table->boolean('isAdmin')->default(0);

Resources