How to restrict edit only on data display in the index in laravel

I have a problem with my edit.blade.php. In the show view, I have restricted it only on the users’ logged in as you can see in my controller public function index() { $animal = Auth::user()->animals; return view(‘farms.index’, compact(‘animal’)); } And my index view @extends(‘layouts.app’) @section(‘content’) <div class=”container”> <div class=”row justify-content-center”> <div class=”col-md-8″> <div class=”card”> <div…

Use Axios defaults in laravel vapor signed-storage-url

Using Tymon jwt tokens for auth. Laravel works fine. When using the upload to S3 code for Laravel vapor I cannot get the signed-storage-url to use my axios defaults: axios.defaults.headers.common[“Authorization”] = ‘Bearer ‘ + token; Store Method as shown in the docs: Vapor.store(this.$refs.file.files[0], { progress: progress => { this.uploadProgress = Math.round(progress * 100); } }).then(response…

laravel file upload throws an error “file does not exist or is not readable.”

I’m trying to upload an image to images folder. if ($request->hasFile(‘pic’)) { $file = $request->file(‘pic’); $file_name = time() . ‘.’ . $file->getClientOriginalExtension(); $destinationPath = public_path(‘/images/’); $file->move($destinationPath, $file_name); $model->pic= $file_name; } But i get this error : The “./././php4E16.tmp” file does not exist or is not readable. I’m uploading a photo for a post in other…

error handler not catching error 500 in Laravel

The following is the function in the handler.php file : public function render($request, Exception $exception) { if ($exception instanceof CustomException) { return response()->view(‘errors.500′, [], 500); } return parent::render($request, $exception); } I have a blade named 500.blade.php in the following path : C:\xampp\htdocs\sharp\resources\views\errors The following is error 500 that I’m trying to handle (without any handling)…

how to restrict user with another id to update other user comment in laravel

public function update (Request $request, $id, $commentid) { $this->validate($request, [ ‘body’ =>’required|max:255′ ]); $post = Post::findorFail($id); $comment = Comment::find($commentid); $body = $request->body; $comment->post_id = $post->id; $comment->body = $body; $comment ->user_id = Auth::user()->id; $comment ->save(); return response()->json([‘data’ => $comment], 200, [], JSON_NUMERIC_CHECK); } how to restrict other user->id to update auth->id comment and use select method…