Category : laravel-7

My policy for an API controller seems to be working fine for view, but returns ‘This action is unauthorized.’ for viewAll, both while sending an admin api token. Using Laravel 7 with Spatie Roles/Permissions. AppBaseController extends IlluminateRoutingController. I’ve tried it without the middleware, just to be sure. Tried commenting out the ‘before’ function, to make ..

Read more

I’ve three models: product.php class Product extends Model { protected $table = ‘products’; // many to many relationship with product and attribute. public function attributes() { return $this->belongsToMany(Attribute::class); } } Attributefamily.php { use HasFactory; protected $table = ‘attributefamilies’; protected $fillable = [ ‘name’, ‘order’, ]; public function scopeAsc($query) { return $query->orderBy(‘order’, ‘asc’); } public function ..

Read more

Two collections: $users = User::select(‘id’,’name’)->get(); //outcome [{"id":"1","name":"John"},{"id":"2","name":"Peter"}] $orders = Orders::all(); //outcome [{"id":"1","userid":"1"},{"id":"2","userid":"2"}] How to modify $orders collection "userid" value to replace with real names instead of numeric? I would like to send that to view without modifying database. Expected outcome of $orders: //outcome [{"id":"1","userid":"John"},{"id":"2","userid":"Peter"}] Sourc..

Read more

I have two tables as ‘customers’ and ‘transactions’. all the transactions related to customer gets stored in transactions. Here i want latest record of each customer from transactions table. Here is my query $customers = DB::table(‘customers’) ->join(‘transactions’, ‘customers.id’, ‘=’, ‘transactions.custId’) ->where(‘customers.status’, ‘Active’) ->select(‘customers.id’, ‘customers.custName’, ‘customers.custMobile’, ‘customers.custAddress’,’transactions.custTotalReceived’, ‘transactions.custTotalBalance’) ->orderBy(‘transactions.custTotalBalance’,’DESC’) ->paginate(100); expected result shoud be like below ..

Read more

how to save multiple selcet in laravel when I try the script below, not to save this store in controller public function store(Request $request) { $id = $request->id; $post = Rek_medik::updateOrCreate([‘id’ => $id], [ ‘kode_rekmed’ => $request->kode_rekmed, ‘kode_register’ => $request->kode_register, ‘kode_pasien’ => $request->kode_pasien, ‘nama_pemeriksa’ => $request->nama_pemeriksa, ‘tgl_rekmed’ => Carbon::now(), ‘anamnesis’ => $request->anamnesis, ‘pemeriksaan’ => $request->pemeriksaan, ..

Read more

please help me. I upload my laravel project on live server, changed .evn file credencials and changed information in public_html/index.php like: require __DIR__.’/../mysite/vendor/autoload.php’; $app = require_once __DIR__.’/../mysite/bootstrap/app.php’; but I have an error on live server like: Warning: require(/var/home/site/mysite/vendor/autoload.php): failed to open stream: Operation not permitted in /var/home/site/public_html/index.php on line 24 Warning: require(): open_basedir restriction in ..

Read more

I am getting the following error: InvalidArgumentException Unable to locate class or view [ForrestedwQueryUrlBuilderSort] for component [queryUrl-sort]. when I call a component in a package I made like this: <x-queryUrl-sort sort="Group"/></th> This is in the boot method of the service provider for the package: public function boot() { $this->loadRoutesFrom(__DIR__.’/routes.php’); $this->loadViewsFrom(__DIR__.’/resources/views’, ‘forrestedw’); $this->loadViewComponentsAs(‘queryUrl’, [ BoolFilter::class, Search::class, ..

Read more

Currently I have a laravel build acting as a REST API. All is working as expected. The issue is, I want to add the ability to batch update a selection of records using laravel’s resource route implementation. This is my current API route code: routes/api.php Route::apiResources([ ‘user’ => ‘APIUsercontroller’, ‘company’ => ‘APICompanyController’, ‘car’ => ‘APICarController’, ..

Read more

I have installed laravel application and ran the first ‘php artisan migrate’ command that migrated the users table successfully. I then created other migrations for 2 more tables but when I run same command, I get this errors Migrating: 2014_10_12_000000_create_users_table Process finished with exit code 255. I have noted with other applications which were running, ..

Read more

I’m just a student and fairly new using Laravel with vue.js. I’m using Laravel-mix version 6.0 in laravel-7 and after running mix I get this error (Uncaught Type Error: Cannot set property ‘$Gate’ of undefined) in public/js/app.js.console error description. Due to this the routes are not working, and are visible disable. The error line in ..

Read more

maybe you could help me about my current issue. I have Product that got some has many relations /** Inherits from : category, subcategory and model */ Product->hasMany(CategoryAttributes, $this->category) Product->hasMany(SubCategoryAttributes, $this->subCategory) Product->hasMany(ModelAttributes, $this->model) /** */ Product->hasMany(HideForSubcategoryAttributes, $this->subCategory) Product->hasMany(IgnoreForModelAttributes, $this->model) Now I need to implement something that gives me all attributes for the Product. collect the ..

Read more

I have two tables as customers and transactions. In transaction all the transaction related to customer gets stored. Now i want all the data from customers table and only sum of ‘received amount’as received from transactions table. Below is query $customers = DB::table(‘customers’) ->join(‘transactions’, ‘customers.id’, ‘=’, ‘transactions.custId’) ->where(‘customers.status’, ‘Active’) ->select(‘customers.id’, ‘customers.custName’, ‘transactions.custTotalReceived as Received’) ->paginate(100); ..

Read more

I wrote the query to get the student’s age but I want to have the breakdowns with age and the count. This is my query to getting each student’s age. $students = DB::table(‘students’)->select(DB::raw(‘TIMESTAMPDIFF(YEAR, stud_dob, CURDATE())+0 AS age’))->orderBy(‘age’)->get(); And I used one query to get the breakdowns but it’s giving the wrong count for the students. ..

Read more