vendredi 21 février 2020

Class controller not found

I'm trying to do a referral links app. And when I want to do the 'where' into the RefCategory(Controller) it gives that error when I refresh the page or access. I tried to put into the controller the path with USE but nothing, the error still occurs.

Here's the error that display:

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class 'App\Http\Controllers\RefCategory' not found

Here is the code from the RefCategory:

namespace App\Http\Controllers;

use App\Http\Requests\CreateRefCategoryRequest;
use App\Http\Requests\UpdateRefCategoryRequest;
use App\Repositories\RefCategoryRepository;
use App\Http\Controllers\AppBaseController;
use Illuminate\Http\Request;
use Flash;
use Response;
use Auth;
use App\Controllers\RefCategoryControllers;

class RefCategoryController extends AppBaseController
{
    /** @var  RefCategoryRepository */
    private $refCategoryRepository;

    public function __construct(RefCategoryRepository $refCategoryRepo)
    {
        $this->refCategoryRepository = $refCategoryRepo;
    }

    /**
     * Display a listing of the RefCategory.
     *
     * @param Request $request
     *
     * @return Response
     */
    public function index(Request $request)
    {
        $refCategories = $this->refCategoryRepository->all();

        return view('ref_categories.index')
            ->with('refCategories', $refCategories);
    }

    public function refs($user_id = null, $ref_category_id = null){

        //user_id
        if(!$user_id){
            return redirect(route('/login'));

        }

        if($ref_category_id){
          $refCategory = RefCategory::where('id', $ref_category_id)->first();
            RefCategory::where('id', $ref_category_id)->update([
                'referral_visits'=>$refCategory->referral_visits + 1,
                'referral_count'=>$refCategory->referral_count + 1
                ]);
        }
        dd($user_id); 
    }

    /**
     * Show the form for creating a new RefCategory.
     *
     * @return Response
     */
    public function create()
    {
        return view('ref_categories.create');
    }

    /**
     * Store a newly created RefCategory in storage.
     *
     * @param CreateRefCategoryRequest $request
     *
     * @return Response
     */
    public function store(CreateRefCategoryRequest $request)
    {
        $input = $request->all();
        $input['user_id'] = Auth::user()->id;

        $refCategory = $this->refCategoryRepository->create($input);

        Flash::success('Ref Category saved successfully.');

        return redirect(route('refCategories.index'));
    }

    /**
     * Display the specified RefCategory.
     *
     * @param int $id
     *
     * @return Response
     */
    public function show($id)
    {
        $refCategory = $this->refCategoryRepository->find($id);

        if (empty($refCategory)) {
            Flash::error('Ref Category not found');

            return redirect(route('refCategories.index'));
        }

        return view('ref_categories.show')->with('refCategory', $refCategory);
    }

    /**
     * Show the form for editing the specified RefCategory.
     *
     * @param int $id
     *
     * @return Response
     */
    public function edit($id)
    {
        $refCategory = $this->refCategoryRepository->find($id);

        if (empty($refCategory)) {
            Flash::error('Ref Category not found');

            return redirect(route('refCategories.index'));
        }

        return view('ref_categories.edit')->with('refCategory', $refCategory);
    }

    /**
     * Update the specified RefCategory in storage.
     *
     * @param int $id
     * @param UpdateRefCategoryRequest $request
     *
     * @return Response
     */
    public function update($id, UpdateRefCategoryRequest $request)
    {
        $refCategory = $this->refCategoryRepository->find($id);

        if (empty($refCategory)) {
            Flash::error('Ref Category not found');

            return redirect(route('refCategories.index'));
        }

        $refCategory = $this->refCategoryRepository->update($request->all(), $id);

        Flash::success('Ref Category updated successfully.');

        return redirect(route('refCategories.index'));
    }

    /**
     * Remove the specified RefCategory from storage.
     *
     * @param int $id
     *
     * @throws \Exception
     *
     * @return Response
     */
    public function destroy($id)
    {
        $refCategory = $this->refCategoryRepository->find($id);

        if (empty($refCategory)) {
            Flash::error('Ref Category not found');

            return redirect(route('refCategories.index'));
        }

        $this->refCategoryRepository->delete($id);

        Flash::success('Ref Category deleted successfully.');

        return redirect(route('refCategories.index'));
    }
}


via Chebli Mohamed

1 commentaire:

  1. This is how my acquaintance Wesley Virgin's autobiography launches with this shocking and controversial video.

    As a matter of fact, Wesley was in the military-and soon after leaving-he found hidden, "mind control" secrets that the CIA and others used to obtain everything they want.

    As it turns out, these are the same tactics lots of famous people (especially those who "became famous out of nowhere") and the greatest business people used to become wealthy and successful.

    You've heard that you only use 10% of your brain.

    Mostly, that's because the majority of your brain's power is UNCONSCIOUS.

    Perhaps that conversation has even occurred INSIDE your very own brain... as it did in my good friend Wesley Virgin's brain around 7 years back, while driving an unregistered, beat-up trash bucket of a car without a driver's license and on his debit card.

    "I'm absolutely frustrated with going through life check to check! When will I get my big break?"

    You've taken part in those conversations, isn't it so?

    Your success story is waiting to happen. All you have to do is in YOURSELF.

    UNLOCK YOUR SECRET BRAINPOWER

    RépondreSupprimer