Questions tagged [laravel]
48974 questions
1
votes
1
answer
55
Views
ln command behaving mysteriously with Laravel Envoyer
I have a laravel project deployed to AWS. Recently I gave a thought about using Envoyer for zero downtime deployment.
My project has an uploads directory where user uploads are added by code. Of course that's not added in git.
So when envoyer deploys code I have to symlink my uploads folder to the...
0
votes
1
answer
22
Views
How model relationships works with blades?
I have a model 'applicants' and it has a 'belongsTo' relationship with 'BloodGroup' model.
Here is the index function from ApplicantController:
public function index()
{
$user = Auth::user();
// $user = User::find(1);
$applicants = $user->applicants->where('visible', 1);
foreach ($applicants as $app...
1
votes
2
answer
455
Views
Call to a member function addEagerConstraints() on float LARAVEL
My objective is to get average review of the courses available. But when i am trying to get the average review of the course its throwing me an error saying 'message': 'Call to a member function addEagerConstraints() on float'
My Course Model
public function rating(){
return $this->hasMany(Rating::c...
1
votes
2
answer
2k
Views
Retrieving facebook user access token with socialite on laravel 5.4
I am trying to get user access token so I can send CURL request through Guzzle to Facebook's Graph API to get user's friends that are using the app. But I can't seem to be able to obtain it.
Here's my controller:
1
votes
2
answer
277
Views
Crontab isn't running Laravel scheduled jobs
I've set up crontab on my AWS-EC2 instance to hit the Laravel scheduling endpoint every minute via the root account using sudo crontab-e:
* * * * * php ~/htdocs/artisan schedule:run >> /dev/null 2>&1
However, despite to the cron logs showing it is indeed running every minute:
Jan 26 12:02:01 ip-172-...
1
votes
1
answer
296
Views
How can I find whole words only in a LIKE query Laravel?
How can I find whole words in a LIKE query in Laravel's Eloquent?
For example, if someone searched SA the following results can come up with LIKE %sa%:
My name is Sam
I live in SA
But I need a search that only returns:
I live in SA
How can I accomplish this while at the same time preventing SQL inje...
1
votes
2
answer
1.1k
Views
Laravel 5.5 Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' not found
I am working in laravel 5.5 with postgras 9.6, I manage to run all migration and rollback, but when I want to run migration for rename a column in Table i get the Class 'Doctrine\DBAL\Driver\PDOPgSql\Driver' not found error, hire is migration file:
class CreateRenameApplicantIdInBillToApplicationId...
1
votes
2
answer
364
Views
Best way to write Group routes with prefix in laravel 5.5
What is the best and correct way to write the following routing:
Route::group(['middleware' => ['web']],function (){
Route::prefix('user')->group(function () {
//this address shows the login page
Route::any('login', '[email protected]_page');
//others address that control the login action
Route::prefix('lo...
1
votes
3
answer
2.1k
Views
Laravel: laravel.log permission denied
When I try to open my Laravel app I get the following error:
UnexpectedValueException
The stream or file '/laravel/storage/logs/laravel.log' could not be opened:
failed to open stream: Permission denied
Why is this and how can I fix it?
1
votes
3
answer
45
Views
Laravel changing the inner join via user input
My Plan is the following.
I have this inner join:
SELECT cd.fk_lend_id,cd.serialnumber ,customers.name,cd.created_at
FROM cd
INNER JOIN customers ON cd.fk_lend_id = customer.lend_id
Where cd.fk_lend_id = 00000000;
This is what it would look like in Laravel:
$scores = DB::table('cd')
->join('cd', 'c...
1
votes
1
answer
540
Views
Class 'PragmaRX\Tracker\Vendor\Laravel\ServiceProvider' not found
I had installed PragmaRx\Tracker package several months ago into my project.
I started to deleting the package from laravel project through following steps:
1. composer remove vendor/PragmaRx/Tracker
2. remove package name form composer.json file
3. removing package from provider and aliases list in...
1
votes
2
answer
831
Views
How do I properly push JSON array onto existing data array in Vue JS on a Axios response?
I think this is a general Javascipt question however I am working in Vue Js, Laravel & Axios.
How do I push one JSON array into another JSON array? My problem is that when I push the secondary array into the primary array it is nested (see screenshot). I need it as part of the same array.
Is th...
0
votes
2
answer
23
Views
Merge two array and create new
I have problem to create array. I have form.
Form's inputs are tag inputs. First input is option name. When you put any option name the new tag input added in the form.
I post data in controller and create auto variations for product. Eg. Red-S Red-M Blue-S Blue-M ... The Code which i'm using gives...
0
votes
0
answer
14
Views
Passing the language parameter to the next page (url) when submitting the form
I'm having problems with getting the right language parameter in the url when submitting a form.
My application has two possible language parameters: de and en.
I've made a middleware called setLocale.php with this function:
public function handle($request, Closure $next)
{
$locale = $request->seg...
0
votes
2
answer
11
Views
Dynamic Global Variables
I am new in web development and using laravel framework for my 1st project. I am trying to define a dynamic global variable.
My problem is as under :
I want to setup two types of app users. One that are fixed to a specific branch and second who will select a branch. I have added a branch_id colum...
0
votes
0
answer
8
Views
Laravel two similar routes, second route not found
Laravel 5.8, I have two routes:
Route::get('/exam-info/{id}', '[email protected]')->name('main_exam_info');
Route::get('/exam/{id}', '[email protected]')->name('start_main_exam');
When I go to the second route it gives me 'page not found' error! Why?
0
votes
0
answer
4
Views
“Trying to get property 'id' of non-object (View: C:\xampp\htdocs\CERCAA\resources\views\admin\posts\edit.blade.php)”
When I am editing the post then it's showing
'Trying to get property 'id' of non-object (View: C:\xampp\htdocs\CERCAA\resources\views\admin\posts\edit.blade.php)'
1
votes
1
answer
319
Views
Chrome doesn't work for vuejs v-on:click in option tag
I have something like the following code :
@{{category.category_name }}
It works fine in firefox but doesn't work in chrome and safari.
in other words @click doesn't work in chrome when it's in an option tag.
It's obvious that I'm using vuejs.
any idea?
1
votes
1
answer
30
Views
Can I get the table id of a file uploaded earlier in the same function?
I wanna set the parent_id of images that are gonna get uploaded using a loop to the id of an image I uploaded earlier in the function. I could just make a query to the database but I was wondering if there's a better solution.
$image = new Image();
$image->name = $title;
$image->description = $descr...
1
votes
1
answer
427
Views
Add new auto increment column to existing table
My old migration is:
Schema::create('item_tag', function (Blueprint $table) {
$table->integer('item_id')->unsigned()->index();
$table->foreign('item_id')->references('id')->on('items')->onDelete('cascade');
$table->integer('tag_id')->unsigned()->index();
$table->foreign('tag_id')->references('id')->...
1
votes
1
answer
308
Views
How to get PhpStorm to recognize Laravel facades?
When using Laravel Framework (5.6), PhpStorm does not recognize methods when accessed via facades like this:
$user = User::find($id);
So it's always complaining that: 'Method 'find' not found in User'
I've got the Laravel Plugin & the Barry IDE Helper. What else do I need to do?
1
votes
1
answer
863
Views
How to paginate with Vuetify and Laravel?
Goodnight
I'm trying to do server side paging with Vuetify and Laravel.
But the methods provided by Vuetify have not worked for me to do it correctly. I have a completed page that I want to implement with the Vuetify components.
I attach my code made with simple bootstrap.
thumb_down
thumb_down
Meth...
1
votes
1
answer
293
Views
How to Make Login API with Laravel 5.6 Passport from Different Table and Guard
How to make login API token with Laravel 5.6 passport from other table (visitors, not users) and different guard (visitor).
Its working when i use default laravel auth table (users), but i need login from visitors table.
this is my auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider'...
1
votes
4
answer
321
Views
Laravel - whereHas checking latest record of a relationship without checking others
I have two tables that has One to Many relationship.
Bookings - (id)
booking_tasks - (id, booking_id,user_id)
one booking has many task
one task has one booking
Booking Model:
public function tasks() {
return $this->hasMany('App\BookingTask');
}
BookingTask Model
public function booking() {
retu...
1
votes
3
answer
182
Views
Laravel hasMany return null
I have model Category:
class Category extends Model
{
protected $fillable = ['title', 'description', 'keywords', 'slug'];
public function getRouteKeyName()
{
return 'slug';
}
public function products()
{
return $this->hasMany(Product::class);
}
}
And have model product:
class Product extends Model...
1
votes
2
answer
63
Views
Store Data in Multiple tables via single form
I want to store data in 3 tables via single registration
form but getting error. I have tried all the way but it is not
allowing due to primary key constraints violation
Controller
class UserController extends Controller
{
public function registerLawyer(Request $request){
$firstname = $request->get(...
1
votes
2
answer
378
Views
Laravel - convert array into eloquent collection
I need to use data from an API.
I create a function:
public function getItems()
{
$client = new \GuzzleHttp\Client();
$res = $client->get('https://app.example.com/api/getItems');
$vouchers = json_decode($res->getBody(), true);
dd($vouchers);
return view('api', compact('vouchers'));
}
and dd($voucher...
0
votes
1
answer
15
Views
How to fix “Warning: Invalid argument supplied for foreach()”
I'm making a website in Laravel, CSS, and HTML.
The current issue is that my code, won't gather information from files inside the folder '_videos' with this 'summon' code.
@foreach ($videos as $video)
{{$page->title}}
@endforeach
Error message
Warning: Invalid argument supplied for foreach()
Folder:...
0
votes
1
answer
17
Views
How do I concatinate strings in attr
I want to concatenate strings in attr using jquery
I have already tried using + but it doesn't get the value of the variable:
var job_id = $(this).attr('value');
if(confirm('Are you sure you want to delete this? This will be removed permanently')){
$('.job_delete').attr('href', '{{ route('job_delete...
1
votes
1
answer
35
Views
How to add unique constraint to column with LongText datatype in laravel 5.7
Can i add unique constraint to LongText column in laravel.
I mean, for example i have table having body column with LongText datatype, then how i can make it unique.
$table->LongText('body')->unique();
When i do this it will generate the following SQL error.
Illuminate\Database\QueryException : SQL...
1
votes
2
answer
53
Views
How to add multiple ckeditor using class in a one page?
I am trying to add multiple ckeditor using single class in a page. By clicking on add more link I want to add dynamic ckeditor. Following is my code.
CKEDITOR.replace( 'editor1' );
1
votes
1
answer
44
Views
Unable to send email s using Laravel
I'm new on Laravel and I'm trying to configure mail. My .env file is configurated as:
MAIL_DRIVER=SMTP
MAIL_HOST=vserv.******.***
MAIL_PORT=587
[email protected]******.***
MAIL_PASSWORD=*********
1
votes
1
answer
19
Views
How to get an array from a single field from related model in laravel?
The following:
Customer::with('tickets:customer_id,subject')->get();
returns the following:
[
{
'id': 1,
'company': 'Test Ltd',
'support': 'Standard',
'tickets': [
{
'customer_id': '1',
'name': 'Test ticket 1'
},
{
'customer_id': '1',
'name': 'Test ticket 2'
}
]
}
]
How can I flatten the related fie...
1
votes
3
answer
37
Views
Laravel collections convert key value to key assoc array
I use this function: $assets->pluck('url').
It outputs: ['link','link1','link2']
How to convert it to: [{url: 'link'}, {url: 'link1'}, {url: 'link2'}]
1
votes
1
answer
34
Views
Laravel resource and related tables
I am getting my posts with resources and with this posts I also collect their categories but the categories come with full data, I need to limit returned data of categories,
Sample
1
votes
3
answer
62
Views
How to access image from /storage -laravel- from SPA with vuejs
if i put an image in 'storage/app/public/img/logo.png' and execute:
$ php artisan storage:link
How i get that logo.png in vue component?
The requested it's ok (200) but that image not render, because is an SPA.
Thank you,
1
votes
1
answer
33
Views
How to get data out of the notifications?[Error retrieving data] laravel 5.8
When ever a user post on a thread its send an notifications and then form the navagition bar there is an drop down menu where the user can see all his notifications, but when I try to open it it gives an error
Undefined index: thread (View:
C:\Users\Merlijn\AppData\Roaming\Composer\Laravel
Projects...
1
votes
2
answer
39
Views
Laravel Seeder - create 2 users with my own selected emails by seeder
here is what we have in user factory by default
$factory->define(User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'r...
1
votes
2
answer
24
Views
Laravel: Use same column as option name and its value in select box/drop-down?
I'm trying to create a form with a select box in Laravel.
View
{{ Form::select('cmp_type', $cmp_types, null, $attributes = ['class' => 'form-control']) }}
Controller
public function showAddCompany()
{
$cmp_types = cmpTypes::where('status', true)->pluck('type');
return view('addCompany', compact('cmp...
1
votes
2
answer
44
Views
laravel Show only related data in search filter
I am trying to create a search filter:
if ($request->has('street')) {
$streets->where('name', 'like', '%'.$request->street.'%');
}
if ($request->has('house')) {
$streets->whereHas('properties', function ($query) use ($request) {
$query->where('house_number', $request->house);
});
}
return $streets->...