msabiry

msabiry

Member Since 1 Week Ago

Experience Points 200
Experience Level 1

4,800 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

10 May
1 week ago

msabiry left a reply on All Other Crud Working Except Update

@SNAPEY - Many many thanks bro Finally I fixed it

msabiry left a reply on All Other Crud Working Except Update

@SNAPEY - I putted the email field back, but the result still same

msabiry left a reply on All Other Crud Working Except Update

@SNAPEY - The result is same bro Sorry to bother you

msabiry left a reply on All Other Crud Working Except Update

@SNAPEY - It didn't know Rule: The error is right now: Class 'App\Http\Controllers\Rule' not found

msabiry left a reply on All Other Crud Working Except Update

@SNAPEY - How should be validation of email ?

msabiry left a reply on All Other Crud Working Except Update

@SNAPEY - No I haven't laravel debugger. See this is my validation and hasn't any error It works for store but won't work for update,

public function validateRequest()
    {
        return tap(request()->validate([
            'fName' => 'required|max:24',
            'lName' => 'required|max:24',
            'email' => 'required|max:64|email|unique:customers',
            'message' => 'nullable',
            'active' => 'required',
            'company_id' => 'required',
        ]), function (){
            if (request()->has('image')){
                request()->validate([
                    'image' => 'file|image|max:5000'
                ]);
            }
        });
    }

msabiry left a reply on All Other Crud Working Except Update

@JLRDW - Resource works with all of them It makes simple your code, My code works with resource completely with all methods of CRUD except update

msabiry left a reply on All Other Crud Working Except Update

@SNAPEY - I tried old on your way but still not working bro Logically and technically my code is best and should work but I don't know where is the problem

msabiry left a reply on All Other Crud Working Except Update

@SNAPEY - It works but after this code It didn't work $customer->update($this->validateRequest());

msabiry left a reply on All Other Crud Working Except Update

@EDOC - It says: MethodNotAllowedHttpException The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE.

msabiry left a reply on All Other Crud Working Except Update

@EDOC - Yes bro I can store data without any problem, but can't update And it doesn't show any error

msabiry left a reply on All Other Crud Working Except Update

@JLRDW - Everything is ok with it Storing, viewing and deleting records works correctly, but editing won't work I can't update my records

msabiry left a reply on All Other Crud Working Except Update

<?php

namespace App\Http\Controllers;

use App\Company;
use App\Customer;
use Intervention\Image\Facades\Image;

class CustomerController extends Controller
{

    // Extends middleware('Auth')
    // Only Authorized Users can access this routes
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index()
    {
        $activeUser = Customer::active(); // Active is a scope from Model
        $inactiveUser = Customer::inactive(); // Inactive is a scope from Model
        $companies = Company::all();

        return view('customer', compact('activeUser', 'inactiveUser', 'companies'));
    }

    // Create Records
    public function create()
    {
        $companies = Company::all();
        $customer = new  Customer();
        return view('customer', compact('companies', 'customer'));
    }

    // Save Records
    public function store()
    {
        $customer = Customer::create($this->validateRequest()); // Getting data from validateRequest() function

        $this->storeImage($customer);

//        event(new NewCustomerHasRegisteredEvent($customer));

        return back()->with('success', 'Added Successfully!');
    }

    // Show Records
    public function show(Customer $customer)
    {
        $companies = Company::all();
        return view('profile', compact('customer', 'companies'));
    }

    // Edit Records
    public function edit(Customer $customer)
    {
        $companies = Company::all();
        return view('profile', compact('customer', 'companies'));
    }

    // Update Records
    public function update(Customer $customer)
    {
        $customer->update($this->validateRequest());

        $this->storeImage($customer);

        return back();
    }

    // Delete Records
    public function destroy(Customer $customer)
    {
        $customer->delete();
        return redirect('customers');
    }

    public function validateRequest()
    {
        return tap(request()->validate([
            'fName' => 'required|max:24',
            'lName' => 'required|max:24',
            'email' => 'required|max:64|email|unique:customers',
            'message' => 'nullable',
            'active' => 'required',
            'company_id' => 'required',
        ]), function (){
            if (request()->has('image')){
                request()->validate([
                    'image' => 'file|image|max:5000'
                ]);
            }
        });
    }

    public function storeImage($customer)
    {
        if (request()->has('image')){
            $customer->update([
                'image' => request()->image->store('images', 'public'),
            ]);

            $image = Image::make(public_path('storage/' . $customer->image))->fit(60, 60, null, 'top-left');
            $image->save();
        }
    }
}

msabiry left a reply on All Other Crud Working Except Update

@JLRDW - I don't know y I can't post code

msabiry left a reply on All Other Crud Working Except Update

@NASMED - Error doesn't show This is my controller:

msabiry started a new conversation All Other Crud Working Except Update

Hello dear Please help me how can I fix this issue My code won't work on update