FAQ Database Discussion Community


Laravel Eloquent how to return one to many to many collection

php,eloquent,laravel-5
Is it possible to get an eloquent relation based on a One->Many->Many relationship? In the below example, I would want to get all of the gallery_votes for a given user. users +----+---------------+ | id | user_name | +----+---------------+ | 1 | bob | | 2 | sam | +----+---------------+ galleries...

How can I Echoing Data After Checking For Existence in PHP Laravel 5?

php,laravel,laravel-5
I don't have anything store on my user phone field at the moment. <li><i class="md md-phone"></i> {{ $user->phone or 'No Phone' }} </li> So this line should print out No Phone. But instead it print out as blank. I'm confuse. What did I do wrong /forgot ? Is it because...

Can't install guzzlehttp for Laravel

laravel-5,guzzle
I am using PHP 5.4 and I have Laravel 5.1 for my development. When I try to install guzzlehttp through composer for my Laravel I get error that your PHP 5.4 doesn't specify the requirements. i tried to install it by lowering the version like composer require "guzzlehttp/guzzle": "5.0" but...

Getting code from my forked repository

git,laravel,repository,laravel-5,composer-php
I made a fork from a repository called "chrisbjr/api-guard". the repository latest version is v2.2.2, and I made a release v2.2.3 from my fork. I have my own branch which is dev-fulluth, to get the code from my fork not from the main repo, composer has to contain the below...

Laravel 5.0: Form::select() called twice Eloquent Accessor by select name

php,laravel,eloquent,laravel-5,accessor
Blade template: {!! Form::model($category) !!} {!! Form::select('drinks_id', [...full list...]) !!} {!! Form::close() !!} 'drinks_id' called by Eloquent Accessor: public function getDrinksIdAttribute() { var_dump('get'); return 123; } When Form::select('drinks_id') execute, getDrinksIdAttribute() called twice and print string(3) "get" string(3) "get" from var_dump(). If I write this: {!! Form::model($category) !!} {!! var_dump($category->drinks_id) !!}...

Laravel 5 - How to get Auth user ID in controller, retrieve user data and display that data in view

php,laravel-5
New to the Laravel 5 framework (and OOP), I want to create a view where a user can view/edit his own user profile when he's logged in. What would be the syntax to get Auth user ID in controller, retrieve user data (from DB) and display that data in the...

Restrict laravel to open url that is not in route

php,laravel,routing,laravel-5,laravel-5.1
I am Learning laravel now. Today I came across a problem that surprised me. I open this link in my browser: http://localhost/laravel/project/ch/resources/views/pages/blog.blade.php And I expect error 404. but it opens contains of this file. So, How to restrict laravel to do this. I want laravel to open only url mentioned...

How to register global variable for my Laravel application?

php,laravel,laravel-5
I have started with Laravel a few days ago, and today I just installed the vespakoen/menu that seems to be very nice, and probably will work for what I need it. Currently I have installed Laravel 5.1 on my system. The problem I currently have, is where to register my...

Trying to connect Ionic App to a Laravel API

angularjs,laravel,laravel-5,ionic-framework,ionic
I'm building an Ionic app and trying to use Laravel 5 as my API. I've got the a basic user signin/signup/forgot/reset UI in place and am learning how to use ngResource, but in order to test this I want to hit the localhost Laravel is running on. Ionic serve is...

Cannot insert the value NULL into column 'user_id', table 'dbo.role_user'; column does not allow nulls

php,laravel-5,rbac
I am using Zizaco/Entrust in Laravel 5.0 to apply RBAC and i'm having the following error: Cannot insert the value NULL into column 'user_id', table 'dbo.role_user'; column does not allow nulls. INSERT fails. (SQL: insert into [role_user] ([role_id], [user_id]) values (2, )) I followed all the steps to implement Entrust...

Sync element to a child on Laravel

php,mysql,laravel,eloquent,laravel-5
My Shema database is User Table id login parent Sign Table id name user_id (Sign owner) Pivot table user_sign id user_id sign_id My User model contain public function signs() { return $this->belongsToMany('App\Sign', 'user_sign'); } public function parent(){ return $this->belongsTo('User', 'parent'); } public function children(){ return $this->hasMany('User', 'parent', 'user_id'); } And...

Add DropzoneJS for file upload with Laravel 5

php,laravel,laravel-5,dropzone.js
I have a form with with files uploading input that is working well but I want replace it with DropzoneJS to add drag and drop functionality but any files get uploaded with DropzoneJS. This what my wiew looks like: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Testing DropzoneJS with Laravel...

Laravel put foreach inside mail

php,laravel,laravel-5,sendmail,swiftmailer
i want use a foreach inside my mail function, but i'm not sure how to do that, (i'm using swiftmailer, but that's not really relevant i think) here is my code: Mail::send('emails.bestelling', array( 'mededeling' => $bestelcode, 'rekeningnummer' => '000/000000/00', 'naam' => $userNaam, 'totaal' => $totaal, 'producten' => foreach ($mand as...

Laravel 5 not storing checkbox value

php,laravel,checkbox,laravel-5
We are having a strange issue with Laravel 5 in that it is refusing to store the checkbox value. We are adapting the existing registration form that comes bundled with Laravel 5 and we are adding an optin checkbox but it seems the model does not recognise this as a...

Laravel query builder 'where' method is broken

php,mysql,laravel,laravel-5
Any example from http://laravel.com/docs/5.1/queries using ->where(...) fails for me. Generated query always has question marks instead of passed values. Code: var_dump( DB::table('users') ->where('votes', '>=', 100) ->toSql() ); Outputs: string 'select * from `users` where `votes` >= ?' (length=40) ...

Laravel 5 Modify Mass Assignment

laravel-5,mass-assignment
How I can change the fillable attribute of a model on the fly? For example, I have User model with, protected $fillable = ['name', 'email', 'password'] When updating the user, I want to exclude 'email' from mass assignment so that the email is not changed on update....

Eloquent Query always returns null for parent table using oneToOne relationship

php,laravel,eloquent,laravel-5,one-to-one
Parent Table users schema | 'id','email','pass' Relationship public function profile() { return $this->hasOne('App\Profile','user_id'); } Other Table profiles schema | 'id','user_id'/*foreign key to users table */ ,'address','city' Relationship public function user() { return $this->belongsTo('App\User','id'); } I'm querying Profile model and would like it to eagerload with User model. public function edit($id){...

FatalErrorException: Call to a member function count() on a non-object

php,database,random,laravel-5,unique
I'm trying to generate a unique/random string in Laravel 5 and check it through my table to see if it exists. This is what I have, but it seems to be giving the error stated in the title: public static function generate() { $exists = true; while ($exists) { $code...

Laravel 5 How to Pass 2 Models to a Form

php,forms,laravel,model,laravel-5
I have form and i am using form model binding. My form is {!! Form::model($vehicle,['url' => '/pages/store']) !!} <table style="width:650px; margin-left: 4px;" > <tbody> <tr> <td>ID</td> <td>Model</td> <td>Brand</td> <td>License Plate</td> </tr> <tr> <td>{!! Form::text('id' ,null , ['readonly'], ['class' =>'textboxlong form-control', 'style'=>'height:23px;']) !!}</td> <td>{!! Form::text('model' ,null ,['class' =>'textboxlong...

How can I move file in php Laravel 5 ?

php,laravel,laravel-4,laravel-5
I'm trying to move file from one place to another place. In this case is my user profile picture. Since I store my user profile picture base on their username, so when they change their username. I will need to move thier profile photo, Otherwise, the image link will be...

File makeDirectory

laravel-5
I can make a Folder Successfully when a user create his account based on his chosen username but I also want to instruct make sub folders for instance when you create an account with username "john" a folder is created called "john" what about if I want to create sub...

Laravel 5.2 Job with delay fires instantly instead of waiting

php,laravel,laravel-5,jobs
I'm creating an application with the Laravel 5.2 framework. In my application there is a job that I want to fire 2 days after the event. This is the code where an instance of the right job is made and where I set the delay to the amount of seconds...

Get base_url using Jquery in Laravel

jquery,laravel,laravel-5
I am using laravel 5.0. I want to get base url of laravel page using jquery. I have tried the following function. function getBaseURL () { return location.protocol + "//" + location.hostname + (location.port && ":" + location.port) + "/"; } But this gives only http://localhost. I need my full...

Laravel 5 : on success Validation Request function

laravel-5,laravel-validation
In laravel 5, we can now use the Request classes for input validation like so : public function store(StoreItemRequest $request) { $item = Item::create($request->all()); return 'success'; } When the validation fails, I can get the errors thanks to the response function in the Request class : public function response(array $errors)...

Physical delete a model which is enabled softdelete in laravel5?

php,mysql,laravel,laravel-5,soft-delete
I am using SoftDeletes for a model in Laravel5. But in some cases (Keeping history is not useful),I want to do physical delete (Removing row from table)instead of softDelete. class PaymentInvoices extends Model { use SoftDeletes; } Is there any method for forcing physical delete? ...

laravel 5 ->getRealPath() doenst show correct value

php,laravel,laravel-5,intervention
On my local development I use the code shown below, which works perfect, but when I uploaded the site to combell everything worked fine except my file upload. I already determined that the problem is involving ->getRealPath(), when I dd(); that I get this path: /data/sites/web/christophvhbe/tmp Which doesn't exist on...

Input::all() empty after FormData object passed

javascript,jquery,laravel,laravel-5,form-data
I have a form that I need to process before it's submitted. The form has several text and radio inputs, as well as a file one. I'm using jQuery to pass the form data: $button.on('click', function(e) { e.preventDefault(); var formData = new FormData($('.js-my-form')[0]); $.ajax({ type: 'GET', url: '/get-data', data: formData,...

Laravel 5.1 throws ReflectionException after upgrade from 5.0

laravel,laravel-5
I have recently upgraded Laravel to version 5.1 from 5.0, but whenever I send an API response to the server, it throws an exception like the following: ReflectionException in RouteDependencyResolverTrait.php line 57: Class App\Http\Requests\User\GetRequest does not exist Before upgrading everything was working fine. This is the autoload section of my...

Laravel 5 : get route parameter in Controller 's constructor

laravel,laravel-5
I defined routes for a controller this way : /model/{id}/view /model/something/{id}/edit I need to get the id parameter in the contructor of this controller. For example : class ArtController extends Controller { public function __construct(Request $request){ //dd($this->route('id')); //Doesn't work //dd($request->segments()[1]); //this works for the first route but not the second...

Laravel - Guzzle not returning any data even though URL is correct

php,laravel,laravel-4,laravel-5,guzzle
I am trying to return the JSON data from a third party API - http://postcodes.io/. I currently have in my controller: $client = new Client(); $request = $client ->get('https://api.postcodes.io/postcodes/'.Input::get('postcode')); $statusCode = $request->getStatusCode(); if ($statusCode >= 200 && $statusCode < 300) { $json = Response::json($request); // Returns JSON decoded array of...

How to make morre readable URIs using unique-id-plus-redundant-information (UPRI) using PHP with Laravel

rest,laravel-5,url-routing
I would like to know the best (and most consistent) way to add redundant bits to my restful uris so that they are more readable while remaining unchanging when some things such as username change. I read of the concept at this excellent blog post and it is something like...

Cannot get parameter value from url in main page

laravel,laravel-5
I searched a lot for the issue. But I couldn't find anything related to getting parameter value from get request in app.blade.php file. URL: http://localhost:8000/project/dashboard/1 I want to get this parameter value after user is signed in. Following is the code in AuthController. if ($this->auth->attempt($request->only('email', 'password'))) { return redirect()->route('dashboard', ['id'...

Laravel 5 on shared hosting getting internal server error

deployment,ftp,laravel-5,shared-hosting
I am trying to get my Laravel 5 project running on my shared hosting through FTP. I have uploaded all my project files from my local XAMP-folder to the server root directory and put the files in the 'public' folder in the public_html folder. When I go to mydomain.com I...

Creating an Eloquent Object with relation included

php,laravel,eloquent,laravel-5,foreign-key-relationship
I'm pretty much new to opps and laravel both So, to insert the values into my users and profiles table which hav OneToOne relationship, Here is how my store() method looks like public function store(Requests\StoreNewUser $request) { // crate an objct of user model $user = new \App\User; // now...

Guzzle error 500

php,laravel-5,guzzle
so i have a CURL request that looks like this (and it works): curl -X GET -H "Authorization: Token 1234567890" http://api.website.com tried translating it into Laravel Guzzle into something like this: $client = new \GuzzleHttp\Client(['base_uri' => 'http://api.website.com']); $headers = ['Authorization' => 'Token 1234567890']; $response = $client->get($query_string, $headers); return $response; but...

How to validate an input date from individual day, month, year input in Laravel 5

php,date,laravel-5
I have a user registration form which takes input birth day split in 3 different input fields i.e. day, month, year {!! Form::selectMonth('month', null) !!} {!! Form::selectRange('day', 1, 31, null) !!} {!! Form::selectYear('year', Carbon\Carbon::now()->year, (new Carbon\Carbon('100 years ago'))->year, null) !!} In the backend I have modified the Registrar.php/validator() to check...

Laravel 5 MethodNotAllowedHttpException

php,laravel,laravel-5,laravel-routing
I am using a form with PATCH method and I have a button link(since i already have a submit button and using same form for both store and update) as <a class="btn btn-default" href="{{ URL::to( 'pages/edit/' . $vehicle -> id) }}">EDIT</a> And my route is Route::patch('/pages/edit/{id}', ['uses' => [email protected]']); Controller...

Using slugs in laravel 5?

laravel-5,slug
I have made eloquent-sluggable work on my app. Slugs are saved just fine. Buuuut... How do I use it to create a pretty url? If possible, I would like to use them in my url instead of ID numbers....

Laravel-5 'LIKE' equivalent (Eloquent)

php,mysql,laravel-5
I'm using the below code to pull some results from the database with Laravel 5. BookingDates::where('email', Input::get('email'))->orWhere('name', 'like', Input::get('name'))->get() However, the orWhereLike doesn't seem to be matching any results. What does that code produce in terms of MySQL statements? I'm trying to achieve something like the following: select * from...

Update enum column in Laravel migration using PostgreSQL

postgresql,laravel,laravel-5,laravel-migrations
According to this answer, I have to run a raw query if I want to update an enum in MySQL. But with PostgreSQL, I can't use this query, and enum type for PostgreSQL in Laravel seems strange. Is there any way to update enum in a migration for postgreSQL ?...

Laravel method attributesToArray() not running on production

php,laravel,laravel-5
I'm deploying my application to my production environment and it's not working as expected. I've narrowed the issue down to one line inside this loop in my controller; foreach($temp_table_data as $a_payment) { //array_push($payments, $a_payment->payment); //big collection object array_push($payments, $a_payment->payment->first()->attributesToArray()); //smaller object } The error I get is call to a...

laravel 5.1 not seeing changes to Job file without VM restart

php,laravel,laravel-5,homestead
I have created a new Job in a laravel 5.1 app, running in Homestead VM. I've set it to be queued and have code in the handle method. The handle() method previous expected a param to be passed, but is no longer required and I've removed the param form the...

Automaticlly attach to pivot table in Laravel 5

php,eloquent,pivot,relational-database,laravel-5
I currently have a Users to Groups Relationship (ManyToMany) with a pivot table group_user. I want the user to be able to create a group but once creating the group, how do I make it, that the creator becomes member of this group? Currently I have My Pivot Table (group_user):...

Laravel 5.1 AWS S3 Flysytem: AWS HTTP error: cURL error 6: Couldn't resolve host name

curl,file-upload,amazon-s3,laravel-5,host
I'm on my local environment and are about to enable file uploading to AWS s3, using Laravel 5.1 Flysystem/Filesystem. All setup has been done. I have created a test form, and I'm trying to upload a file. When I push the submit button, I get this absolutely, only too lovable...

Laravel 5 form request validation returning forbidden error

php,validation,laravel,laravel-4,laravel-5
I am trying to use Laravel 5.1's form request validation, to authorize if the request is from the owner. The validation is used when the user is trying to update part of the table clinics through the show.blade.php. My set up so far: routes.php: Route::post('clinic/{id}', array('as' => 'postUpdateAddress', 'uses' =>...

Laravel - can I control routes by rule?

php,laravel,laravel-5,laravel-routing
So I have a Laravel Controller (MainController.php) with the following lines: ... public function _settings_a(){ return view('_settings_a'); } public function _settings_b(){ return view('_settings_b'); } public function _settings_c(){ return view('_settings_c'); } public function _settings_d(){ return view('_settings_d'); } public function _staff_a(){ return view('_staff_a'); } public function _staff_b(){ return view('_staff_b'); } public function...

Laravel GET parameters that include dots cannot be checked

php,laravel-5
I'm trying to determine whether a parameter is in the URL or not. I use: $request->has('key'); And it's been working properly until now when I have to check wethere I have openid.ns parameter in the URL. If I remove the .(dot) everything works as expected, but: URL: myhost.dev/auth/login?openid.ns=http://google.bg/ And then...

Error while Eager loading a Eloquent model with multiple relationship in Laravel 5

php,laravel,eloquent,laravel-5,relationship
My User model have two relationships public function group(){ return $this->belongsTo('App\Group','group_id'); } public function profile() { return $this->hasOne('App\Profile','user_id'); } And Accessing them in Controller like $users = \App\User::with('group','profile')->get(); However, Retriving Profile Model's column give error (Inside a @foreach loop ) @foreach ($users as $user) URL::action([email protected]',[$user->profile->id]) @foreach ($users as $user) Error...

full text search with multiple text input

sql,laravel,input,full-text-search,laravel-5
I'm trying to do a full text search with two text input fields. public function searchmatch() { $hex = Input::get('HEX'); $rgb = Input::get('RGB') $products = DB::table('products')->whereRaw( "MATCH(HEX,RGB) AGAINST(? IN BOOLEAN MODE)", array($hex,$rgb) )->get(); return view('search')->with('products', $products); } However it does not work. I tried storing both inputs into an array...

Laravel Seeding: date manipulation not working

php,database,postgresql,laravel-5,php-carbon
I have a pivot table that I want to seed. Besides the PK and the FK, the table also contains two more columns: Arrival & Departure (type: timestamps). I'm using Carbon to populate randomly the preceding columns. Here's my code: $faker = Faker::create(); for( $i=0 ; $i<55500 ; $i++){ $nowDt...

Getting NotFoundHttpException when accessing a image file in uploads directory in Laravel 5.1

php,.htaccess,laravel,wamp,laravel-5
My setup WAMP Windows 8 I have an uploads directory in iapp <- Root Directory uploads app public Virtual Hosts file (httpd-vhosts.conf) NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot C:/wamp/www/ ServerName localhost </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "C:/wamp/www/iapp/public" ServerName iapp.dev ErrorLog "logs/iapp.dev-error.log" CustomLog "logs/dev-iapp.dev-access.log" common <Directory "/"> Order Deny,Allow Deny from...

Laravel 5 - Nest Resource index method resource ID

php,laravel,laravel-5,laravel-routing,nested-resources
I try to make a default controller base on the Laravel Restful Controller, and I'm block with the index method with Nested Resources. I have a route Route::resource('photos.comments', 'DefaultController'); and I need to get the photo_id in my index method. But so fare, I only get {photos}. public function index(Request...

Laravel 5 View is loading from cache and new code not affecting

php,laravel,laravel-5,blade
I have been working in my Vagrant development environment and the Laravel 5 app is working fine. When I uploaded the app to my DO Ubuntu 14.14 droplet, its loading the View from cache and when I update the view blade template, its not affecting the site. Last 1 hour,...

Mysql - Laravel - order by and rownum position not in sync in 2 queries

php,mysql,sql-order-by,laravel-5,rownum
So I have a list of users, who receive votes, they are ordered by votes DESC, but then I have another query that gets their current position I.E. 1st place, 2nd place, 10th, place, etc. The problem is when people have the same number of votes, the position isn't in...

Retrieving the Slug from URL for function (Laravel 5)

php,eloquent,laravel-5,blade,slug
I'm making an App where a group is created by a user. This user can go to the group page (automated unique slug is created for the groups). My goal is for the member who created the group, to be able to make a invite code for that specific group....

Angular - Uncaught ReferenceError: angular is not defined

javascript,php,angularjs,laravel-5
I'm trying to use a simple Angular function in my Laravel 5 project and I keep getting this error: angular is not defined I have tried to move angular.min.js to the top making it the first JS script on my index page but it still doesn't work. This is my...

Laravel: Best practice for inline PHP in a blade file

php,laravel,laravel-5,blade
So I have the following blade file: confirmEmail.blade.php @extends('layouts.master') @section('title') {{ trans('tc.signUpConfirmTitle')}} @endsection @section('body') <div class="container"> <div class="row"> <div class="col-lg-4"> &nbsp; </div> <div class="col-lg-4"> <?php echo $_GET['emailToken']; $emailToken = isset($_GET['emailToken']) ? $_GET['emailToken'] : ""; $email = isset($_GET['email']) ? $_GET['email'] : ""; //database lookup: $user = User::where('email','=',$email)->first(); //this...

Laravel 5 redirect after store

php,laravel,redirect,laravel-5,laravel-routing
How to redirect a route after store process at L5 ? My route is Route::get('/pages/aracislemler/{id}', ['middleware' => ['roles'], 'uses' => [email protected]', 'roles' => ['Admin']]); And controller function public function store() { $brand_name = Request::get('brand_id'); $type_id = Request::get('type_id'); //$client_id = Request::get('representive_client_id'); if (!Brand::find($brand_name)) { $brand = new Brand; $brand -> brand_name...

How to turn an s3 object string into something useful when using laravel 5.1 filesystem

php,amazon-s3,laravel-5,file-conversion,flysystem
I'm at a loss. I'm trying to display an object (image.jpg) I successfully have uploaded to my s3 bucket. I have made sure the file is set to public. I use the Storage::get(); method which the doc says "returns a string of the object". See here: The get method may...

Merging collections

laravel,eloquent,laravel-5
I have a raw query: $data = Product::hydrateRaw(//sql here); This returns a collection. I then perform a further query: $data2 = Product::take(3)->get(); I then wish to merge both collections: $data->merge($data2); Unfortunately the merge appears to have no effect, when I dd() the collection only contains $data and not $data2. Where...

Redirect to Login page if ther user not logged in Laravel

laravel,laravel-5,laravel-routing
I am using Laravel version 5. I have a route file for my project which contains plenty of lines. I need to put authentication like Redirect to login page if the user is not logged in. And I also want to prevent direct URL access if the user not logged...

PHP custom sort on an object array Laravel-5

php,arrays,laravel-5
I need to build a custom sort on an object array but i'm not sure where to start. I've seen the functions usort() etc but I can't see how i'd implement these functions for what I require. My application is returning the below object array. I need to order it...

Laravel 5.1, Return response to user, then excute some code [closed]

php,android,laravel,android-gcm,laravel-5
The Story I am using NotificationPusher that uses GCM to send notification to user. It takes some time to connect to google server and wait for response. So, I don't want my user to wait until notification is sent, I want him to get the response (say that he successfully...

Nested queries, multiple tables in Laravel

laravel,laravel-5
How to write the following query in eloquent or query builder in Laravel SELECT * FROM creatives WHERE creative_id IN (SELECT creative_id FROM term_relationships WHERE term_id IN (1, 2, 3) GROUP BY creative_id HAVING COUNT(*) = 3) My db model has the relationships defined for the above two tables. Here...

Setting up a second Homestead Laravel app

laravel,laravel-5,homestead
I've been trying to set up a second Laravel 5 app on my local Homestead space. I have been following the instructions from the official documentation and from this blog. (Although I have had to use the specific ID of the provision in order to get the vagrant provision command...

Laravel validator vs requests

laravel,laravel-5,laravel-validation
Hello, I want to understand how to handle data validation with Laravel 5. I see that this can be done using or the validator, or the request files. The thing is that there are many points I didn't get. What is the difference between using a request file for validation...

The box 'laravel/homestead' could not be found

php,ubuntu,laravel,vagrant,laravel-5
Trying to configure laravel 5.1. Cloned the laravel/homestead After cloning it to Home directory. Throwing error when tried to run the vagrant up command as below: [email protected]:~/laravel/homestead$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... There are errors in the configuration of this machine. Please fix the following errors...

Laravel 5 confirmation error message display in wrong field

laravel,laravel-5,laravel-validation
I would like to check if there is an error in my code I did not realize but why is my confirmation field's error message keep on displaying in the wrong filed? Suppose I have a password field and a password_confirmation field, but every time when user made a mistake...

Laravel 5 getting input values that are arrays

php,laravel,input,laravel-5,laravel-form
I have a text field like {!! Form::textarea('representive[address_1]' ,null ,['class' =>'textboxlong form-control','style'=>'height:60px;']) !!} In my form. And when i try to get its value in my controller but it comes null. What i try is $adress = Request::get('representive.0.address_1'); I also tried some other ways but could not end up with...

Handling 500 Internal Server Error from DomDocument in Laravel 5

php,laravel,exception-handling,laravel-5
The library I wrote for Laravel uses DomDocument. I use this library under my Controller, and its namespace is app/Services/Verify/. The library gets initialized and used when I put it some inputs into a form. When the library fails, Laravel would fail the way it would - returning the following...

Laravel 5 making a route for a specific link

laravel,laravel-5,laravel-routing
I have a link that goes to a address like http://localhost/pages/vehicles?show=61 Is it possible to make a route for that kind of link i tired below route but it does not work Route::get('/pages/vehicles?show={id}', ['middleware' => ['roles'], 'uses' => [email protected]', 'roles' => ['Admin']]); ...

Laravel5: Access public variable in another class

php,class,oop,laravel,laravel-5
I have a middleware file called LanguageMiddleware.php: ... class LanguageMiddleware { //ISO language codes: public $languages = ['en','es','fr','de','pt','pl','zh','ja']; ... LanguageMiddleware.php is in laravelProj/app/Http/Middleware/ Here's my problem: I have a blade template file called master.blade.php where I'm attempting to output a list of languages @foreach (App\Http\Middleware\LanguageMiddleware\languages as $lang) <a class=\"setLang\" href=\"lang/en\">{{...

Retreiving a single colum from a pivot table - Laravel 5

php,laravel,eloquent,laravel-5
I am using a pivot table genre_user to relate user to genre. table contains the following fields id user_id genre_id Following are the model definitions User.php public function genres() { return $this->belongsToMany('App\Genre'); } Genre.php public function artists() { return $this->belongsToMany('App\User'); } I am getting the results as a collection when...

Laravel 5: Call method in class before the method indicated by the route

php,laravel,laravel-5,laravel-middleware
I'm sure there's a well documented way to do this in Laravel, I'm just missing it or not understanding what I'm reading. I have an application that uses a token for accessing part of the website, rather than a username or password. That token identifies the job, checks the status...

Laravel 5 form submit creates an error MethodNotAllowedHttpException

php,forms,controller,routes,laravel-5
I'm using Laravel 5. When editing a form a get this error MethodNotAllowedHttpException There are a few posts but I think it may be code specific. I'd rather not use the resource route methods if possible. Route: Route::get('profile/edit', array('as' => 'admin.profile.edit', 'uses' => [email protected]')); Route::post('profile/edit', array('as' => 'admin.profile.update', 'uses' =>...

Change extends(layout) dynamically in laravel 5

layout,laravel-5
I have been trying to change layout dynamically in laravel by just passing a variable in @extends('default1.master') to $var = default2 @extends('$var.master') possibly @extends($var.'.master') tried a lot but unable to find a solution all I get is error in my syntax or view not found....

How to add and make sure there's one space after every

and before

php,laravel-5
I am comparing string and displaying differences. These text string might have tags. Problematic situation is when two tags are not separated with a space, example: <p>Some random text</p> is compared to <p><strong>Some random</strong> text</p>. In this case diff algorithm thinks that 1st diff is <p>Some and <p><strong>Some and to...

How can I use Elixir + Vueify?

javascript,laravel,laravel-5,vue.js
How can I use Elixir + Vueify like the Vue-Hackernews sample? They use some command like this at the package.json .... "scripts": { "dev": "watchify -v -t vueify -e src/main.js -o build/build.js", "build": "./node_modules/watchify/node_modules/.bin/browserify -t vueify src/main.js | uglifyjs -c -m > build/build.js" } ... But I do not know...

Share value from database in all view in laravel 5

laravel-5
I'm new to laravel. I'm trying to create a simple app with some variable that shouold be in every view. So I create a setting model, with many fields and a unique slug field. Now to share this variable from database I've created a middleware: public function handle($request, Closure $next)...

Laravel 5 - Sending group emails

php,laravel,laravel-5
I am using Mailgun to handle email in my Laravel 5.1 application. There are times when I need to email a large number of users at once, such as internal group emails and alert notices. So far, I have created an array of recipient email addresses, sent the email to...

What is the best practice to implement update profile picture in PHP Laravel 5?

javascript,php,jquery,laravel,laravel-5
I'm trying to allow my user to update their profile photo and I'm wondering what is the best practice to implement something like that in Laravel. Here is my user profile picture. When they hover on it, they will have an option to update their photo. When the user click...

Upgrade to Laravel 5.1 - Method [validator] does not exist

laravel,laravel-5
Last night, I upgraded my application from 5.0 to 5.1 . Everything seems to be working fine, except the registration. On entering the information, and registering, I get this error: BadMethodCallException in Controller.php line 282: Method [validator] does not exist. Not able to figure out where do I have to...

laravel file uploading using json

jquery,ajax,json,laravel,laravel-5
I am using laravel 5. I have did the following code to post data using json to my controller. But I cannot make file uploading by this manner. e.preventDefault(); $.ajax({ type: 'POST', cache: false, dataType: 'JSON', url: 'tasks', data: $('#my_form').serialize(), success: function(data) { console.log(data); }, }); I have the following...

L5 Paypal Integration - Finding Controller method

laravel,laravel-5
I am trying to integrate Paypal into my Laravel 5 site using this package: http://packalyst.com/packages/package/netshell/paypal When I go to: /paypal/checkout though, I get this error: InvalidArgumentException in UrlGenerator.php line 561: Action App\Http\Controllers\[email protected] not defined. This is my route: Route::get('/paypal/checkout', [ 'as' => 'get-paypal-checkout', 'uses' => [email protected]' ]); And this is...

Only execute methods if session value laravel 5

php,laravel,laravel-5
I have a controller with alot of methods than should only be allowed to be executed if I have a certain value in my session. This is what I do at the moment: I made a private method that can either return the value 'yes' or 'no' Wich I call...

Correct way to run a select query from blades in laravel 5 using eloquent

php,mysql,laravel,eloquent,laravel-5
What is the Correct Way to retrieve a column value based on certain select filter on a Model variable availed by compact method inside the blade. (Larevl 5) I read that Its a bad practice to query database staright from views, and hence i followed the convention to avail the...

Laravel and Geocoding markers (nearby users) do not update correctly

javascript,google-maps-api-3,laravel-5
I try to show on a google map markers that are near the current positon. If the map is dragged it will update the center coordinates and recalculate the markers around that center. The initial markers around the current users positon are showing correctly but when i drag the map...

Laravel 5 pagination with trailing slash redirect to 301

php,laravel,redirect,pagination,laravel-5
I'm using Laravel 5 and notice that the pagination is adding a trailing slash before the ?page=# and with that, it always redirect to a 301 page. http://example.com/news/articles/?page=2 will do a 301 redirect to http://example.com/news/articles?page=2 This is causing my pagination using ajax to slow down because it is having 2...

Laravel 5 : [Call to a member function getAction() on a non-object

laravel,laravel-5,laravel-routing
In my Controller, I have Route::getCurrentRoute()->getAction()['as'] Everything works well in the browser but as soon as I type php artisan route:list in the terminal I have this exception [Symfony\Component\Debug\Exception\FatalErrorException] Call to a member function getAction() on a non-object If I comment this line everything works well....

What is the best practice to create a custom helper function in php Laravel 5?

php,laravel,laravel-5,view-helpers
I have the default created_at date keep printing out as an MySQL format : 2015-06-12 09:01:26. I wanted to print it as my own way like 12/2/2017, and other formats in the future. I created a file called DataHelper.php and store it at /app/Helpers/DateHelper.php - and it looks like this...

How can validate only a certain fields in php Laravel 5?

php,validation,laravel,laravel-5
I'm currently working on my Edit form in my Laravel application. I request all the inputs from a form submit. I got : array:6 [▼ "_method" => "PUT" "_token" => "iWyonRYFjF15wK8fVXJiTkX09YSPmXukyGbBcHRA" "phone" => "9786770863" "email" => "[email protected]" "address" => "23 School St Lowell MA 01851" "$id" => "1" ] My...

Maximum function nesting level of '100' reached, aborting after upgrading to Laravel 5.1

php,laravel-5,homestead
Am getting this error message in my Laravel application after I upgraded to Laravel 5.1. FatalErrorException in Dispatcher.php line 200: Maximum function nesting level of '100' reached, aborting! This issue occurs on some URLs of my app. I have done dozens of composer update but issue still persist. Any suggestion...

Class 'User' not found - Laravel 5.1 [php artisan db:seed]

php,laravel-5
(Before I say anything I WILL say that I have looked around on stack and google and found NO solutions to this problem, I have also tried the infamous composer dump-autoload function, I always use it before the DB seed after making any changes to please DO NOT tell me...

How to change User Table in Laravel?

php,mysql,authentication,laravel,laravel-5
I use Laravel 5.0. I have user table in my DB. I changed table variables in User and Config/Auth to user but when I try to register Laravel gives me an error: Table 'xxxx.crmx_users' doesn't exist (SQL: select count(*) as aggregate from `xxxx` where `email` = xxx What I do...

Laravel route model binding for just one route

php,laravel,laravel-5
I have a controller with 8 methods. Seven of them use this statement: $item = Item::findOrFail($id); However, only one needs a different query: $item = Item::with('subitem')->findOrFail($id); I would like to define a route model binding for the first seven of these methods, however, is there a way to somehow tell...

Deleting migrations results in an Exception

php,laravel,laravel-5,composer-php,autoload
In my Application, when I run php artisan migrate:make create_location_user_table, then delete the generated file (doesn't matter if I delete the line created in vendor/composer/autoload_classmap.php, the php artisan migrate:refresh command throws an error: include(<path_to_project>/database/migrations/2015_06_21_105357_create_location_user_table.php): failed to open stream: No such file or directory After running commands to get rid of...

Why is ::class appended to PHP class in Laravel 5.1

php,namespaces,laravel-5
In Laravel 5.0 code like this is used for names-pacing/loading classes: 'providers' => [ /* * Laravel Framework Service Providers... */ 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', ] However, am seeing this in Laravel 5.1 'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Foundation\Providers\ArtisanServiceProvider::class, Illuminate\Auth\AuthServiceProvider::class,...

How to get an item from a collection in Laravel 5?

php,laravel-5
I'm new to Laravel and I cannot figure out how to get the value of an item from within the returned collection. Here is my code: $aircraft = Aircraft::join('pams_shared.shared_aircraft', 'aircraft.shared_aircraft_id', '=', 'pams_shared.shared_aircraft.shared_aircraft_id') ->select('aircraft.*', 'shared_aircraft.*') ->where('aircraft.owner_id',Auth::user()->owner_id) ->where('registration',$reg) ->get(); I want to get the value from aircraft.aircraft_id but that's where I get...

Laravel 5.1 View not found

php,laravel,laravel-5,blade,homestead
this seems to be an issue that pops up every now and then within Laravel. I was writing a CRUD controller with a view to go with it, however upon testing I got the InvalidArgumentException in FileViewFinder.php line 137: View [bookingcrud.index] not found error. Here is my code: routes.php: Route::resource('bookingcrud',...

Unable to override automatic model find method calls since upgrading to Laravel 5.1

laravel,laravel-5
I have a simple trait which I use to always include soft-deleted items for a few things: trait OverrideTrashedTrait { public static function find($id, $columns = ['*']) { return parent::withTrashed()->find($id, $columns); } } However, since upgrading to Laravel 5.1, this no longer works. Soft-deleted items do not turn up in...