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

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

Related

Laravel 8 How to restrict user login if email is not verified

I am using Bootstrap Starter template package in Laravel 8 that replaces Tailwind CSS framework with Bootstrap CSS framework.
https://packagist.org/packages/shahvirag/laravel-ui-bootstrap
The problem I'm having is that user can sign in after registration without needing to verify account through email. How can I restrict his access until the email is not verified?
I have followed the steps and tried using routes middleware, but there is no such file in App\Http\Controllers\PagesController;
Route::get('/',[PagesController::class, 'index'])->name('users')->middleware('verified'); // this does not work
Any help?
routes/web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PagesController;
Route::get('/', function () {
return view('main');
});
Route::middleware(['auth'])->group(function() {
Route::get('/home', function() {
return view('home');
})->name('home');
Route::get('/user/profile', function() {
return view('profile');
})->name('profile');
});
Route::get('/',[PagesController::class, 'index'])->name('users')->middleware('verified');
resources/views/auth/login.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">{{ __('Login') }}</div>
<div class="card-body">
<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>
</div>
</div>
</div>
</div>
</div>
#endsection
To use verified middleware, your user model should implement MustVerifyEmail
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;
// ...
}
Try this instead
Route::get('/',[PagesController::class, 'index'])->name('users')->middleware(['auth', 'verified']);
You can use the method included with the User model:
$user->hasVerifiedEmail()
Or in the routes middleware(['verified'])

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?

syntax error, unexpected 'layouts' (T_STRING), expecting ')' (View: C:\xampp7\htdocs\shopping\resources\views\auth\register.blade.php)

ican not open to page "register.blade.php" when I click to register itt alert this error
syntax error, unexpected 'layouts' (T_STRING), expecting ')' (View: C:\xampp7\htdocs\shopping\resources\views\auth\register.blade.php) I can open page login.blade.php
my code in app.blade.php::
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
#if (Route::has('register'))
<li class="nav-item">
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
</li>
#endif
There is a problem with your Register helper function, you are missing ')
<button type="submit" class="btn btn-primary">
{{ __('Register}}
</button>
Change to
<button type="submit" class="btn btn-primary">
{{ __('Register')}}
</button>
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

How can I get it to validate my inputfield

The inputfield dosn't get validated it make a postrequest anyway wether or not the validations is valid
I have watched and followed serial youtube vidos, without any lock.
I have also tried to read the documentation but I couldn't find the error
MY Controller:
public function changepassword(Request $request)
{
$request->validate([
'passwordA' => 'string', 'min:8', 'same:passwordB',
'passwordB' => 'string', 'min:8',
]);
}
My view:
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card">
<div class="card-header">Profil</div>
<div class="card-body">
<form method="POST" action="userprofile">
#csrf
<div class="form-group row">
<label for="username" class="col-sm-2 col-form-label">Username</label>
<div class="col-sm-10">
<input class="form-control" type="text" id="username" placeholder="{{ $user->email }}" readonly>
</div>
</div>
<div class="form-group row">
<label for="name" class="col-sm-2 col-form-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" placeholder="{{ $user->firstname }} {{$user->surname}}" readonly>
</div>
</div>
<div class="form-group row">
<label for="phone" class="col-sm-2 col-form-label">Phonenumber</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="phone" placeholder="{{ $user->telephonenr }}" readonly>
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
<label class="col-sm-12 col-form-label">Rest password</label>
</div>
</div>
<div class="form-group row">
<label for="passwordA" class="col-sm-2 col-form-label">New-Password</label>
<div class="col-sm-10">
<input type="password" class="form-control #error('passwordA') is-invalid #enderror" id="passwordA" name="PasswordA">
#error('passwordA')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<div class="form-group row">
<label for="passwordB" class="col-sm-2 col-form-label">Type again</label>
<div class="col-sm-10">
<input type="password" class="form-control #error('passwordB') is-invalid #enderror" id="passwordB" name="PasswordB">
#error('passwordB')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
<button type="submit" class="btn btn-primary">save</button>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
I was expected to validate the input and when I dosn't fit to the validating criteria the it should show the validation error

Resources