Category : controller

so this is my migration code i have table post that contains a foreign key from department public function up() { Schema::create(‘posts’, function (Blueprint $table) { $table->id(‘id’)->primary; $table->string(‘name’); //$table->unsignedBigInteger(‘user_id’); $table->foreignId(‘dep_id’)->constrained(‘departments’)->onDelete(‘cascade’); $table->timestamps(); }); } this is the controller code class PostController extends Controller { public function getAllPosts() { $posts = Post::get()->toJson(JSON_PRETTY_PRINT); return response($posts, 200); } public ..

Read more

I’m using Laravel 8.0 for my current project and installed package jeremykenedy/laravel-roles and jeremykenedy/laravel-users to achieve user/roles and permissions functionality. Now, I want to update some methods in their controllers i.e. jeremykenedyLaravelRolesAppHttpControllersLaravelRolesController. So for that, I need to override those before updating. Can anyone tell me how to do that? Any help would be appreciated. ..

Read more

Im got error in section elseif, i want make HOD looking only at its own department data public function index(User $user) { if(auth()->user()->role == ‘Admin’) { $form = Form::all(); } elseif(auth()->user()->positions == ‘HOD’) { $form = Form::all()->department(‘user_id’, Auth::user()->id)->get(); } else { $form = Form::where(‘user_id’, Auth::user()->id)->get(); } return view(‘form.index’, [‘list_form’ => $form]); } what should i ..

Read more

i want to pass $data array data to another controller. if I can pass that data to the next controller I can insert that data into the database. what is the correct way to do this functionality class PaymentController extends Controller { public function paymentprocess(paymentRequest $request){ $data=array(); $data[‘name’]=$request->name; $data[‘phone’]=$request->phone; $data[’email’]=$request->email; $data[‘city’]=$request->city; $data[‘address’]=$request->address; if ($request->payment==’esewa’) { ..

Read more

i have this code in controller $Headercategory=Categories::where(‘status’,’1′)->orderby(‘order’)->get(); return view(‘front.home’,[‘Headercategory’=>$Headercategory] all my controlles will include "Headercategory" that mean i have to do same code with all controllers i have. is there any way to make this code public in all project? without no need to add it in all controllers Sourc..

Read more

I have created multiple Resource controller by using the following command: php artisan make:model MobelName -a. There are some model and controller list: Models list: Iof CompanyIof Company Test Controller list: IofController CompanyIofController CompanyController TestController The problem is edit() method only works for Company and Test model. dosen’t works for Iof and CompanyIof model Result ..

Read more

1)When I tried to use Model in update function of controller I get the error? What might be the reason for it. I got error: Non-static method IlluminateDatabaseEloquentModel::update() should not be called statically 2)Another problem is that my delete function doesn’t delete the product. It redirects in another page. What might be the mistake in ..

Read more

I got the following error when I try to write $fillable in Model. IlluminateDatabaseQueryException SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect double value: ‘required’ for column db_productmanagementsystem.products.price at row 1 (SQL: insert into products (title, type, firstname, surname, price, papl, updated_at, created_at) Model: Product.php <?php namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use IlluminateDatabaseEloquentModel; class Product extends Model { ..

Read more

I have a problem loading performance data, it seems because of a query in my controller. I don’t know which query is best for my program. Ask for help for the following query optimization master … My controller public function index(Request $request) { $barang1 = KeluarTmp::LeftJoin(‘data_barang’, function($join){ $join->on(‘data_barang.kode_barang’,’=’,’barang_keluar_tmp.kode’); })->leftjoin(‘data_jasa’,’barang_keluar_tmp.kode’,’=’,’data_jasa.kode_jasa’) ->WHERE(‘barang_keluar_tmp.keterangan’, $user) ->orderBy(‘barang_keluar_tmp.created_at’,’DESC’) ->groupBy(‘barang_keluar_tmp.keterangan’) ->get([‘barang_keluar_tmp.id as ..

Read more

I’m having a problem with my foreach, it doesn’t read the variable I have created in the top. public function checkForPermission($user, $request) { $permission = json_decode($user->role->permission); // echo $rolePermission[0]->name; // echo $request->path(); $hasPermission = false; $path = $request->path(); foreach ($permission as $p) { if ($p->name == $path) { if ($p->read) { $hasPermission = true; } ..

Read more

<?php namespace AppHttpControllers; use IlluminateHttpRequest; use IlluminateSupportFacadesDB; class universityController extends Controller { // public function getStudents(Request $req) { $students= DB::table(‘students’) ->join(‘applicants’, function ($join) { $join->on(‘students.id’, ‘=’, ‘applicants.studentid’) ->where(‘applicants.scholarshipid’,’=’, $req->scholarshipid); }) ->get(); return $students; // return $req->scholarshipid; } } Sourc..

Read more

Hi I have a problem in laravel that has something to do with my database. this is my LoginController: class LoginController extends Controller { function index() { return view(‘login’); } function checklogin(Request $request) { $this->validate($request, [ ‘name’ => ‘required’, ‘password’ => ‘required’ ], [‘name.required’ => ‘Gebruikersnaam is niet ingevuld of niet goed.’, ‘password.required’ => ‘Wachtwoord ..

Read more