Questions tagged [laravel-5.8]

0

votes
0

answer
6

Views

Search with multiple tables

I have 3 tables that are connected/have relation. Posts table have many tag and one Category Category table have many Posts Tag table have many Posts i want a search feature, i know how to search only use Posts (based on title). I tried to search each tables with Where in my controller but still no...
Bonex
1

votes
0

answer
17

Views

How to debug 419 error on LoginPage in Laravel? (Not using AJAX)

Each time I try to login into my Laravel app I get 419 error, thou I have @csrf inside my form tag. I read thru all topics on StackOverflow, but mostly I saw cache: clear and key: generate suggestions, which are not helping me. Also, I've cleaned my browser hundreds of times. Once again it happens o...
Virtual Device
0

votes
0

answer
2

Views

Laravel 5.8 Call to undefined method Illuminate\Events\Dispatcher::fire()

I get this error on user registration. I have searched for this problem a lot and still couldn't solve the problem on my side. In laravel 5.8 upgrade, it's written that function fire() is changed to dispatch(), but I can't find any fire() function in any file of my app, so I can see what's happening...
Hovhannes Mkoyan
1

votes
0

answer
29

Views

Laravel Passport throwing error in AuthServiceProvider

I am not using default laravel authentication from App\User. Below are my codes App\Models\User namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Hash; use App\Http\Controllers\Helpers\SlugController; use Laravel\Passport\HasApiTokens; use Illuminate\Founda...
1

votes
1

answer
43

Views

Laravel Eloquent relationship fetching third table/relation value

I have 3 tables in a database Transaction {'id','bill_id','remark'} Bills {'id','third_party','amount'} ThirdParty {'id','company_name',remark} The 'transaction' table has column bill_id coming from 'Bills' and Bills table has 'third_party' column which connected to ThirdParty table column -> 'id' S...
Khagesh
1

votes
1

answer
14

Views

Strange assertJSON behaviour

I want to test, whether an AJAX response contains the array I'm expecting. So far so good, not really a great deal. This is how my array should look like: array ( 'data' => array ( 0 => array ( 'key1' => 'value1', 'key2' => 'value2, ), 1 => array ( 'key1' => 'value3', 'key2' => 'value4', ), ),...
TimSch
1

votes
1

answer
29

Views

firstOrCreate continuous insert new entry

i run php artisan make:model Models/Test -m create migrate file Schema::create('tests', function (Blueprint $table) { $table->bigIncrements('id'); $table->double('longitude', 9, 4); $table->timestamps(); }); Run migrate and edit Model namespace App\Models; use Illuminate\Database\Eloquent\Model; cl...
Black Jack
1

votes
0

answer
21

Views

Laravel 5: When Creating Model Factory of Enum Datatype Returns InvalidArgumentException: Data missing

I have a table rates for which I want to restrict the rate values from 1 to 5. // Migration file for rates table Schema::create('rates', function (Blueprint $table) { $table->bigIncrements('id'); $table->unsignedInteger('user_id'); $table->morphs('rated'); $table->enum('rate', [1, 2, 3, 4, 5]); $ta...
lizeshakya
1

votes
2

answer
43

Views

dd($var) is working and showing but{{$var}} is giving undefined object Laravel5.8

I get the data that I want to show out of a foreach loop like this @foreach(auth()->user()->unreadNotifications as $notification) {{dd($notification->data)}} {{--{{dd($notification->data['thread']['id'])}}--}} {{--{{dd($notification->data['thread']['subject'])}}--}} {{--{{dd($notification->data['use...
HashtagForgotName
1

votes
0

answer
55

Views

Flash Messages don't work during DB transactions in Laravel 5.7 and 5.8

If I call DB::beginTransaction() in a controller but redirect without calling DB::rollBack() first, my flash messages don't appear on the new page. For example, in a shopping cart, I start a transaction but redirect to the payment page when the credit card payment fails. The payment error doesn't a...
Poldon
1

votes
2

answer
39

Views

Laravel handle error that only thrown by controller

I am creating a logic where a controller can call another controller depend on Auth::user() role, but not all of controller shared same method, so i want if controller calling a method that does not exist it will throw a 404 not found. here is my controller class LokalController extends Controller...
1

votes
1

answer
122

Views

How to retrieve role/status of authenticated user?

I am new to Laravel. I have included an additional field in the user's table named status using the line of code given in the code part below. I am trying to learn how to redirect the user based on their roles. I understand that to retrieve an authenticated user I can use $user = Auth::user(); My...
Muhammad Khan
1

votes
1

answer
22

Views

Defining the queue for an event in Laravel

I have an event and a listener for the Event. So far, the listener is queueable, but it will always be set onto the 'default' queue. In my case, I need this to be flexible, so that I can define the queue when the event is fired. I have not found anything to serve this purpose. What I'd like to do is...
Paladin
1

votes
0

answer
69

Views

“Uncaught ReferenceError: $ is not defined” but jQuery is included

I've an error when I open webpage with jQuery code. Uncaught ReferenceError: $ is not defined I've include jQuery & Bootstrap in app.js and I can't use jQuery in view. In app.js import $ from 'jquery'; window.jQuery = $; window.$ = $; import 'bootstrap'; In layout: @stack('scripts') In view: @push('...
pirmax
1

votes
0

answer
12

Views

syntax error, unexpected ',' in view, but no ',' iin view file

I am getting the error syntax error, unexpected ',' (View: /home/vagrant/code/JCSE/resources/views/comments/caConfirm.blade.php) when I view the following blade file: @extends{'templates.layout') @section('title') Comment Submitted @endsection @section('content') @lang('comments.CA_CONFIRM') @lang(...
BobofMellor
1

votes
0

answer
37

Views

Why do my failed jobs disappear after migration to Laravel 5.8?

I have a Laravel project with a queue, running ~1000 jobs a day. When a job is failing, in 5.7, it was moved to failed_jobs table, and I was able to retry it. After migration to Laravel 5.8, jobs just disappear. This code should mark a job as failed and put it in the failed-jobs table. /** * Execute...
odupont
1

votes
1

answer
27

Views

Authorization gate not called during service provider

I have an admin gate defined in my AuthServiceProvider that is used to add global query scopes to some models. Suppose I had models A, that is observed by an Observer (registered in AppServiceProvider), and B, that makes use of the admin gate to add global query scopes. // app/Providers/AuthServiceP...
1

votes
0

answer
8

Views

I'm getting this error Trying to get property 'title' of non-object (View: C:\Users\wahas\Desktop\Blog\resources\views\projects\edit.blade.php)

I'm trying to edit the form for which i want to render the data into the view into the textbox and textarea but i'm getting the error Trying to get property 'title' of non-object (View: C:\Users\wahas\Desktop\Blog\resources\views\projects\edit.blade.php) under view\projects\edit.blade.php file I ha...
Wahas Ali Mughal
0

votes
0

answer
2

Views

How to insert into a table based on an Eloquent relationship an array of foreign keys

I have two models TeamMember and ProjectRequest. A TeamMember can have one ProjectRequest, that is why I created the following Eloquent relationship on TeamMember: class TeamMember extends Model { // protected $table = 'team_members'; protected $fillable = ['project_request_id']; // Relations public...
Code Worm
0

votes
0

answer
7

Views

Method Illuminate\Database\Eloquent\Collection::post does not exist

Sorry for such a stupid question but im on deadend right now, Im working on a personal project using Laravel (first time btw) and i ran into some problem. I tried to do {{ $kategori->post()->count() }} (this is works btw) but with Users table. I already set the foreign key and stuff. I tried to modi...
Bonex
0

votes
0

answer
7

Views

Make a POST via Ajax to Laravel POST Route

I have a route Route::post('deviceModel/store','[email protected]'); I made an ajax to that route $.ajax({ method: 'POST', // Type of response and matches what we said in the route url: '{{ $APP_URL }}/deviceModel/store', data: {'cpe_mac' : 'B4B6761454F6', 'device_mac' : 'AABBCCCDDEEFF' }, // a...
kyo
3

votes
1

answer
20

Views

Undefined variable when sending data to a view in Laravel 5.8

I have the following problem: I load the main layout (view) of the site in the renderOutput method which is written on the parent controller SiteController. protected function renderOutput(){ $menu = $this->getMenu(); $navigation = view(env('THEME').'.navigation')->with('menu',$menu)->render(); $thi...
Soib
0

votes
0

answer
6

Views

Laravel 5.8 on Homestead - getting 419 on login

I just set up a Windows 10 laptop with all the current versions of Vagrant, node.js, Homestead, Laravel. I then cloned my BtBucket repo (project working perfectly on my Desktop) and did the usual vangrant up --provision, composer install and npm install. Then run the Webpack compile of my assets. F...
TheRealPapa
0

votes
1

answer
12

Views

css and js path corrupted in loading view page on edit method in laravel 5.58

I am new in laravel so i doing a project in laravel .I need to update a record so when i load the edit form then js and css path are corrupted if i don't pass update id among the url then there is no problem. Below is my code edit url is Edit web.php Route::get('/editmarriagepackage/{id}'...
Sherin Green
0

votes
0

answer
3

Views

how to add custom error on response of lighthouse-php

I want a better response for lighthouse-php, because right now it only gives me an error if I throw an exception, Where do I edit or modify the lighthouse response object? this problem came up because of the unauthenticated exception of middleware auth:api, now I don't really like how a simple 'unau...
Grover Reyes
0

votes
1

answer
12

Views

How to create vendor folder during Docker build in Laravel 5.8?

I have a Dockerfile for my Laravel 5.8 project FROM alpine:3.8 as build_stage RUN apk --no-cache add \ php7 \ php7-fpm \ php7-pdo \ php7-mbstring \ php7-xml \ php7-openssl \ php7-json \ php7-phar \ php7-zip \ php7-dom \ php7-xmlwriter \ php7-tokenizer \ php7-session \ php7-zlib && \ php7 -r 'copy('...
kyo
-1

votes
1

answer
25

Views

Optimize Laravel 5.8 Docker image size

I've try my best reduce down the Docker image size of my Laravel 5.8 project. I used to have 193 MB > 115 MB > 57.8 MB Dockerfile (57.8 MB) FROM alpine:3.7 RUN apk --no-cache add \ php7 \ php7-fpm \ php7-pdo \ php7-pdo_mysql \ php7-mcrypt \ php7-tokenizer \ php7-mbstring \ php7-xml \ php7-openssl \...
kyo
1

votes
1

answer
0

Views

Best practise to use code on every page in Laravel

I'm looking for the best practise to implement user notifications in 'app.blade.php' layout. The Layout should always check for user notifications and I don't want to implement in every Controller. Thanks for your ideas.
Smoky
1

votes
1

answer
0

Views

Laravel Dusk how to find elements inside elements?

I'm using Laravel 5.8, Dusk. I would like to find certain elements inside a class. So let's say I extracted every element on the page with the class of selectable. $browser->visit('https://www.website.com') ->script('window.scrollTo(0, 10000);'); $elems = $browser ->pause(1000) ->elem...
Radical_Activity
1

votes
1

answer
0

Views

How to Use Resource Route with group prefix without use `as` method

I want to Use Resource Route and Group prefix Like this Route::group(['prefix' => 'c1'], function () { Route::resource('locations', 'LocationController'); }); but its now working. it's working fine using as method like this Route::group(['prefix' => 'c1'], function () { Route::get('locations', ['as...
Ajay
1

votes
1

answer
0

Views

Laravel: How to make sure a user goes to role-specific home view after registration and after login?

I have created a custom multi-auth system in laravel-5.8 for a college website where every user registers for a specific role: Admin, Faculty, or HOD(Head of Department). I am making use of the controllers and views which we get after running php artisan make:auth Upon registering, all the users ar...
Sushant Kulkarni
0

votes
0

answer
17

Views

Laravel Two Controller and One Model

I'm just playing around with my code and notice that one of my controller is returning empty attributes but the other is returning my data fine. I have two controllers, OneController and TwoController with both resource and same model in it. I use the php artisan make:controller OneController --mode...
jeesoon
1

votes
0

answer
12

Views

How do I show different values in view table using Carbon 'diffInDays'?

I just started using Laravel and in a table cell, in my index view i need to show how many days takes until a product expires using the current date as reference. In my database i already have the expiration date stored. I don't have a field in my database table to store the days difference. I just...
JDB
1

votes
1

answer
31

Views

Laravels syncWithoutDetaching and additional data

I have Googled my fingers sore, and I can't see anyone discussing this, but I have a suspicion that Laravels syncWithoutDetaching() method doesn't take any parameters for extra data like save(), sync() and attach() does? Does anybody know this? In the API documentation the method has the following p...
0

votes
0

answer
4

Views

Problem authenticating APIs with Passport in Laravel 5.8

I've followed the official Laravel docs for installing passport but authentication is failing. Specifically, i'm consuming my API with JS as shown in the docs https://laravel.com/docs/5.8/passport#consuming-your-api-with-javascript. I've checked the cookies and 'laravel_token' is being passed once I...
W.J.A
0

votes
2

answer
11

Views

Laravel 5.8 get tables belonging to a user

I am listing all tables in the DBthat are prefixed with the user->id + _ (eg: 2_my_table) like so: $account = Auth()->user(); $tables = DB::select('SHOW TABLES LIKE '' . $account->id . '_%''); This works and returns an array like this: array:1 [▼ 0 => {#577 ▼ +'Tables_in_mydb (2_%)': '2_country_...
TheRealPapa
1

votes
2

answer
50

Views

composer global require laravel/installer

I've tried the first commands from the Laravel documentation composer global require laravel/installer I got error Changed current directory to /Users/bheng/.composer Using version ^2.0 for laravel/installer ./...
kyo
0

votes
0

answer
15

Views

Laravel sends JSON headers in body

I have the following class that handles JSON responses for me:
Albert
0

votes
2

answer
24

Views

Laravel 5.8 Undefined variable while using “With” Clause

Here is my controller code: $exam_categories = ExamCategory::all(); return view('test.test-home')->withExamCategories($exam_categories); Here is my blade template code: Select @foreach($exam_categories as $examCategory) {{$examCategory->Category}} @endforeach If I run this code then it shows the fol...
Kamlesh Gupta
-1

votes
0

answer
23

Views

How to pass variable from one method to another in Laravel

Please, I need help, I know that this is basic oop but I'm still learning... public function confirm() { $q = Input::get('track'); $confirm = Tracking::where(function ($query) use ($q) { $query->where('tracking_no', 'like', $q ); })->first(); if ($confirm) { return Redirect::to('progress'); } else...
Legendary

View additional questions