Questions tagged [laravel-5.1]

Laravel 5.1 is a past version of the open-source PHP web framework. It has been released on 9th June 2015. Use it in addition to the laravel-5 tag if your question is specific to Laravel 5.1. Use the laravel tag for general laravel related questions.

Laravel 5.1 is a past version of Laravel 5. It has been released on 9th June 2015.

What is new:

  • LTS (Long Term Support)
  • PSR-2 compliance
  • Event broadcasting
  • Middleware parameters
  • Model factories
  • Overhauled testing with new helper traits and a new expressive fluent interface for integration tests
  • Blade service injection
  • Artisan improvements for simplified command signatures and advanced output forms
  • CSRF whitelisting
  • Laravel Envoy allows you to run local scripts without SSH
  • Laravel Elixir compiles ECMAScript 6 by default
  • Backwards-compatible folder structure changes
  • Completely overhauled documentation
  • 5.1.4: Authentication throttling
  • 5.1.11: ACL (Access Control List) authorization

Resources:

4654 questions
29
votes
3 answers

Laravel get name of file

I basically just want to get the name of a file which I get like this: $inputPdf = $request->file('input_pdf'); if I dd($inputPdf) it prints me null.
John Does Legacy
  • 1,123
  • 6
  • 17
  • 28
29
votes
2 answers

printing all running session variable in laravel 5.1

How do I print all running session variable in Laravel 5.1? I want to print all the running session variable. Currently I can retrieve single running session for given value but don't know the function for print all at one time with one function…
prashant sutail
  • 345
  • 1
  • 4
  • 7
29
votes
4 answers

Laravel: connect to databases dynamically

I'm creating an application in Laravel 5(.1) where it is needed to connect to different databases. The only problem is that it's not known which databases it has to connect to, so making use of the database.php in config is not possible. A…
Roboroads
  • 1,242
  • 1
  • 10
  • 20
29
votes
6 answers

Set Auto Increment field start from 1000 in migration laravel 5.1

I need to start my ids from 1000 in user table, how could I create migration for this. My current migration is: public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); // how can I start…
Anshul Mishra
  • 1,576
  • 1
  • 11
  • 36
29
votes
2 answers

When to generate a new Application Key in Laravel?

Since it automatically sets it for me in my .env file when I create the app, I'm not sure when I should run it. In addition to that, if a second developer comes in, and clones the app, does he/she need to run php artisan key:generate ? How do we…
cyb3rZ
  • 43,853
  • 82
  • 251
  • 430
28
votes
8 answers

How to display something only for the first item from the collection in Laravel Blade template

I have a @foreach loop in the Blade template and need to apply special formatting to the first item in the collection. How do I add a conditional to check if this is the first item? @foreach($items as $item)

{{ $item->program_name…

SoHo
  • 559
  • 1
  • 6
  • 19
28
votes
5 answers

File not found at path when trying to copy

I'm trying to copy a file from one location to another. I'm pretty sure the location is correct, but I'm still getting the error in the title. Here's some code: $oDirectory = new \RecursiveDirectoryIterator($extractFolder.'/res'); $oIterator = new…
Alex
  • 4,296
  • 4
  • 31
  • 54
27
votes
4 answers

Call to undefined method Illuminate\Database\Query\Builder::notify()

Issue in Laravel 5.3.6 when submitted request in Forgot Password. Error Details Call to undefined method Illuminate\Database\Query\Builder::notify() Issue is in below file:…
Pankaj
  • 8,971
  • 23
  • 105
  • 242
27
votes
5 answers

Get Laravel Models with All Attributes

Is there a way to retrieve a model in Laravel with all the attributes, even if they're null? It seems to only return a model with the attributes that aren't null. The reason for this is that I have a function that will update the model attributes…
kenshin9
  • 1,737
  • 2
  • 18
  • 30
26
votes
13 answers

Laravel 5.1 DB:select toArray()

I have a large SQL statement that I am executing like so: $result = DB::select($sql); For example $result = DB::select('select * from users'); I'd like the result to be an array - but at the moment it returns a structure like so, an array with…
Yevgeniy Afanasyev
  • 27,544
  • 16
  • 134
  • 147
26
votes
6 answers

Eloquent Parent-Child relationship on same model

I have a model CourseModule, and each of the items are related to the same model. Database Structure: Relation in Model: public function parent() { return $this->belongsTo('App\CourseModule','parent_id')->where('parent_id',0); …
Kiran LM
  • 1,229
  • 1
  • 15
  • 26
26
votes
7 answers

Determining If a File Exists in Laravel 5

Goal : If the file exist, load the file, else load the default.png. I've tried @if(file_exists(public_path().'/images/photos/account/{{Auth::user()->account_id}}.png'))
cyb3rZ
  • 43,853
  • 82
  • 251
  • 430
26
votes
4 answers

Passing a class as function parameter

I'm trying to do something like this: function doSomething($param, Class) { Class::someFunction(); } $someVar = doSomething($param, Class); Is it possible? To explain better what I'm trying to do. I have a helper function in Laravel to generate…
Alex
  • 4,296
  • 4
  • 31
  • 54
26
votes
3 answers

Laravel 5.1 specifing current page for pagination

Been working on this for far too long with no results. I have tried. `\Illuminate\Pagination\Paginator::setCurrentPage($current_page);` returns Call to protected method…
Shane
  • 2,055
  • 4
  • 19
  • 29
25
votes
6 answers

Call Laravel model by string

Is it possible to call a Laravel model by string? This is what i'm trying to achieve but its failing: $model_name = 'User'; $model_name::where('id', $id)->first(); I get the following exception: exception 'ErrorException' with message 'Undefined…
Parampal Pooni
  • 2,618
  • 7
  • 30
  • 37