Laravel redirect back to original destination after login

This seems like a pretty basic flow, and Laravel has so many nice solutions for basic things, I feel like I'm missing something. A user clicks a link that requires authentication. Laravel's auth...

How do I pass a variable to the layout using Laravel' Blade templating?

In Laravel 4, my controller uses a Blade layout: class PagesController extends BaseController { protected $layout = 'layouts.master'; } The master layout has outputs the variable title and...

Check for file existence if Laravel's Blade template

I have a simple problem - how can I check if file exists in Laravel's Blade template? I tried @if(file_exists('/covers/1.jpg')) ok @endif But it doesn't work (covers directory is in /public). I...

Preventing Laravel adding multiple records to a pivot table

I have a many to many relationship set up and working, to add an item to the cart I use: $cart->items()->attach($item); Which adds an item to the pivot table (as it should), but if the user...

increment row number with laravel pagination

How to make increment row number with laravel pagination ? When i use pagination and i go to page 2 and above it will back to beginning. for example i will paginate(3) <thead> <tr> ...

Running one specific Laravel migration (single file)

I don't want to run All Outstanding Migrations on laravel 4. I have 5 migrations. Now I just want to run one migration. instead of doing : php artisan migrate I would like to run one specific...

Pagination with Slim Framework and Laravel's Eloquent ORM

I'm using Slim Framework as router, Twig as Template Engine and Eloquent ORM to handle the database. I created the bootstrap for these libraries. <?php require_once 'vendor/autoload.php'; /** *...

Laravel 4 db seed specific seeder file

I have an existing user table with information seeded via db:seed from UserSeeder.php. Now, I am adding new product table and want to seed information into product table. How can I prevent Laravel...

schema builder laravel migrations unique on two columns

How can I set a unique constraints on two columns? class MyModel extends Migration { public function up() { Schema::create('storage_trackers', function(Blueprint $table) { ...

In Laravel, the best way to pass different types of flash messages in the session

I'm making my first app in Laravel and am trying to get my head around the session flash messages. As far as I'm aware in my controller action I can set a flash message either by...

laravel variable not defined

This is weird. I am sure I am missing something simple. I have the following code: $productToken = Input::get('key'); $products = new Product; $userEmail =...

302 redirect after CORS preflight

I'm running into a problem with a 302 redirect after my CORS preflight has successfully returned a 200 status. I'm currently building an app using Laravel 4.1 and Angular 1.2 as well as my own...

Laravel PDOException SQLSTATE[HY000] [1049] Unknown database 'forge'

I am using Laravel to connect to MySQL database. I got this exception: PDOException SQLSTATE[HY000] [1049] Unknown database 'forge' and this is my config.database.php 'mysql' =>...

How to create multilingual translated routes in Laravel

I would like to create application with many translated routes depending on selected language. I've once described it at 3 methods of creating URLs in multilingual websites. In this case it should...

Laravel Eloquent compare date from datetime field

I want to get all the rows from a table through an expression: table.date <= 2014-07-10 But if the column contains a datetime let's say: 2014-07-10 12:00:00 But if I do: where('date', '<=',...

Schema Builder length of an integer

I've been searching around and the question was asked a few times, but no-one seem to be able to give a definite answer to it. How do you specify the integer length for the table column using...

Laravel: Save Base64 .png file to public folder from controller

I send a png image file to controller in base64 via Ajax. I've already test and sure that controller has received id but still can't save it to public folder. Here is my controller public function...

How to set AUTO_INCREMENT in Laravel with Eloquent?

I am working on an application and my employer wants that the id in the user table should begin from 100,000 instead of 1. How can accomplish that? Is it a parameter in the Schema Builder itself?...

Laravel 5.1 Unknown database type enum requested

While running php artisan migrate, I got the following error [Doctrine\DBAL\DBALException] Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it. How to...

Laravel : How do I insert the first user in the database

I am using Laravel (4.2) I am working on a project with an authentication system. I need to insert a first user into my users table. I would like to do that directly with a sql command (insert...

Is it possible to create a model from mysql database table in laravel

I know that in Laravel we can create a model and migrate them into database. model > migrate > table to SQL server. But my question is there any way to inverse this operation. i.e SQL server >...

How can I update laravel/laravel from 5.3 to 5.4?

I have attempted to update laravel/laravel from 5.3 to 5.4, and to do so, I have modified composer.json to this: { "name" : "laravel/laravel", "description" : "The Laravel Framework.", ...

In laravel npm run dev errors:

I have next errors output running npm command for my laravel 5.6 with bootstrap project: $ npm run dev > @ dev /mnt/_work_sdb8/wwwroot/lar/B4test > npm run development > @ development...

Docker compose with Laravel Dusk

I'm running a Laravel app inside of docker and trying to run browser tests. Since the app and the chromium are running inside of separate containers, I refer to the named container -...

Laravel fails to connect to database while in Docker container

When I run (Laravel 6) php artisan migrate it appears that I am failing to connect to the db with the error: Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] php_network_getaddresses:...

LogicException: Please make sure the PHP Redis extension is installed and enabled

Laravel Version: 7.5.0 PHP Version: 7.2 Database Driver & Version: Redis Everything was working fine but suddenly this error appear i changed the phpredis to predis but error is same. Steps To...

I got de error when I tried install composer league/flysystem-aws-s3-v3

I got de error when I tried install composer league/flysystem-aws-s3-v3 My line: composer require league/flysystem-aws-s3-v3 I using Laravel 8 and php 7.3 I also tested removing...

fclose(): Argument #1 ($stream) must be of type resource, bool given

I just restart my laravel 8.0 project and I got this below error, please what could be wrong, this happens anytime I run "PHP artisan serve" TypeError fclose(): Argument #1 ($stream) must be...

Target class [http\Env\Request] does not exist

I am trying to add auth:api middleware with custom role middleware. I didn't edit anything with the Container, but it broke. Illuminate\Contracts\Container\BindingResolutionException: Target class...

Type Error in Laravel 8 app when package barryvdh/laravel-translation-manager is installed

For last 3-4 weeks I receive this error in my Laravel 8 app, which breaks down my app. After uninstalling the package the problem disappears. Please advice. When using the Laravel...