Most voted "laravel" questions
Laravel is an open-source framework for developing web applications and services with PHP. Before asking consult the official documentation of Laravel.
Learn more…2,777 questions
Sort by count of
- 
		3 votes1 answer514 viewsUsing php Artisan make:RepositoryHi, I’d like to ask you a question. I’m using the remote: php artisan make:repository ProjectNote And I would like to know how do I make the command understand that I want my migrate to have the… 
- 
		3 votes2 answers2143 viewsLaravel - Session and ArrayI need to create an array: array( 0 => 0, 1 => 0, 2 => 1, 3 => 0, 4 => 0, 5 => 1, 6 => 0) within a Session: session('session_array') and then individually add and redeem the… 
- 
		3 votes3 answers2107 viewsRoute access control - Laravel 5.1I have some views that only clients can access, and some that only administrators can access. What I defined in this case is id_client, which if it is "1" is administrator and if it is any other… 
- 
		3 votes2 answers1059 viewsI cannot return the authenticated user in LaravelGood morning In my project, I do the standard authentication provided by Laravel 5, hence it directs to my home usually when logging in. I know that logged in normally because when I put wrong data… 
- 
		3 votes2 answers62 viewsCallback in HavingIn Laravel it is possible to make a callback at the time of a consultation. For example: $q = Model::where(function($query){ $query->where(...); }); I’d like to do something similar, but with the… 
- 
		3 votes3 answers3733 viewsCustomize field name in validation error messagesI’m using the Laravel 5.2 Standard Authentication Controller: php artisan make:auth As the names are in English, I need to change to Portuguese. I have already set the locale to Portuguese, in… 
- 
		3 votes1 answer635 viewsHow to customize the return of an attribute in Laravel?In the Laravel, i know that attributes can return an object of type Carbon\Carbon (an extension of DateTime php), if the field is created_at or updated_at. Example: $usuario = Usuario::find(1); //… 
- 
		3 votes2 answers346 viewsStandard Laravel Input ValueIn the Laravel, I want that when a certain value does not exist in the Input, i can set a default value. With pure PHP, it is possible to do so: $text = isset($_POST['text']) ? $_POST['text'] :… 
- 
		3 votes2 answers620 viewsConvert View with CSS, JS and PDF ImagesI have a view on Laravel where I load multiple charts. This view is composed of HTML, Images, CSS and JS. I need to convert (export) this page to PDF via a JS or PHP function. I can’t find a library… 
- 
		3 votes1 answer603 viewsWatermark image on Laravel 5.2Hello, does anyone know how I could do so that every image that is uploaded in the Watermark has a watermark? The image is sent by a form and through the $request->file('img') in the controller i… 
- 
		3 votes2 answers412 viewsHow to find out what is the first or last item of the Loop in Laravel?I got the following foreach in Laravel. @foreach($values as $value) <li>{{ $value }}</li> @endforeach I would like to add a special information when it comes to the first loop item. In… 
- 
		3 votes1 answer977 viewsHow does Laravel read the file ". env"?How Laravel does to read the file ". env"? I’ve looked in the repositories of Illuminate (from Laravel) and I didn’t find anything that gave me a hint of how to read this file. Is there a library… 
- 
		3 votes1 answer468 viewsWhy use unless in Laravel instead of a no if denial?I think the Laravel an interesting framework. The features of the view are excellent, regarding the simplification of the syntax of a foreach or iffor example. But still one thing I don’t understand… 
- 
		3 votes1 answer649 viewsLaravel 5.2 pages redirecting in the POST without showing validation errorsIn Laravel 5 whenever I try to send a post to save or edit the data, a redirection occurs in all requests with the status 302 . This is occurring on any page of the system where I make a POST to… 
- 
		3 votes1 answer164 viewsHow to get records from a table when there is no relationship with another table in Laravel?In Laravel, when I want to get data from a table that contains some relationship, or when I want to get the data from a condition of a related table, for example, usuarios that contains livros, I… 
- 
		3 votes1 answer295 viewsError using a function within a PHP arrayI’m using the laravel 5.2 and in my class IndexController I am trying to create an array with the function date('Y') thus: <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use… 
- 
		3 votes3 answers357 viewsData bank without foreign key in LaravelI attended a class where a stock system is created in Laravel where there is the product and the category. But there is no foreign key, only one column categoria_id. How is this relationship done?… 
- 
		3 votes2 answers591 viewsPopular select with database valuesI need a select in the form with values from another table. Type: <select> <option value="29">Frentista</option> </select> I wrote my select like this: {{… 
- 
		3 votes1 answer3702 viewsLaravel - validate input arrays and return values in case of errorI am creating form using the following code: In the create.blade.php file {!! Form::open(['route'=>'orcamentos.store']) !!} {!! Form::text('descricao', null, ['class'=>'form-control',… 
- 
		3 votes2 answers1008 viewsHow to Customize Simple Page Arrows?It is very good to use the pagination of Laravel, with a command you do everything: Controller $artigos->simplePaginate(5); View {!! $artigos->render !!} And after that the pagination is… laravelasked 8 years, 11 months ago Diego Souza 16,524
- 
		3 votes1 answer955 viewsWhat are Events in the Flat for?I never used Event in Laravel and I would like to know what is the purpose and if it has some advantage. 
- 
		3 votes1 answer5730 viewsPlease provide a Valid cache pathI just made a git clone (copy) a newly made Laravel application in the company where I work. I surrounded the composer update and artisan key generate to make initial settings as well as edited the… 
- 
		3 votes1 answer83 viewsHow to identify in the constructor the method that was called?How do I stop at builder of my controller identify which method was called? I’m using the Laravel 5.3 and my controller follows the pattern resource (index, show, edit...).… 
- 
		3 votes4 answers8807 viewsHow to convert a date variable to the Brazilian format within a view?Within a index.blade.php have a variable: <td>{{$ordemjoin->dataplanejamento}}</td> In the listing comes the date in the format English. How do I put in the format Brazilian?… 
- 
		3 votes1 answer345 viewsHow to check credentials before authenticating to Laravel 5.3?My application uses Laravel’s ready authentication, but I need users to log in from a web service. So what I’m trying to do is that if the guy exists in the application database, he does Laravel’s… 
- 
		3 votes1 answer714 viewsHow to validate at least one mandatory field?I have two CPF and CNPJ fields, the user must type only one, but never leave the two fields empty. This way it makes mandatory the two fields: [ 'Cpf' => array('required'), 'Cnpj' =>… 
- 
		3 votes1 answer90 viewsSort products interchange according to flagI have a model called Product which has, in addition to product data, a flag featured that says whether the products are featured or not. When mounting the view the products should be displayed… 
- 
		3 votes1 answer438 viewsHow to sort by two parameters with Laravel 5.4?I am making a decreasing order to list winners, but it is based by note. My search is as follows: public function getHistorico($id_avaliacao) { return $this->where('avaliacao_id', $id_avaliacao)… 
- 
		3 votes1 answer2023 viewsWhat’s the point of a Cope on the Laravel?I saw in the documentation of Laravel an explanation about the use of Eloquent. There I saw a part where he talks about Local and Global Scopes. As I do not know much English, I was left with some… 
- 
		3 votes0 answers360 viewsHow to authenticate a javascript application (browser) in a PHP API?Personal, I’m looking to develop a PHP API (Laravel) to consume it both on my SITE (angular) and on the mobile applications I’m still developing. However, I am having trouble implementing a secure… 
- 
		3 votes2 answers3927 viewsHow to edit the routes created by make:auth?I have a project at Laravel where I used the command make:auth to create the views, routes, controllers etc, a registration form. I need to change the a view which is used by default in login for a… 
- 
		3 votes1 answer919 viewsHow to use Laravel paginate with a manual query?I have a query manual on my model, and I want to return to view of blade the result of this paging query. Is there any way? Model class Ticket extends Model { protected $fillable = [ 'id', 'title',… 
- 
		3 votes1 answer283 views
- 
		3 votes2 answers322 viewsHow to compress the output of an HTML in Laravel?I answered that question here once talking about the subject: Store PHP script output in HTML "compressed". But now I’d like to know how I can do it in Laravel. When it comes to an HTML response,… 
- 
		3 votes2 answers7000 viewsLaravel, call Action from a Controller from a View?I have a View where inside it I would like to add the link of a Controller with your Action specifies and when loading this View to Action that Controller be triggered. Example: within a View I have… 
- 
		3 votes1 answer453 viewsSee table row by column name in Laravel?At Laravel I’m looking for a record in the database by id table, but the code below only consults if the nomenclature in the column is id $prod = $this->produto->find(3) If the column name is… 
- 
		3 votes1 answer111 viewsHow to create metadata (custom data) on an Laravel route?I wonder if in Laravel, beyond the information I already have on a route, as the name, action or uri, there is some way to define metadata. For example: Route::get('/', [ 'uses' =>… 
- 
		3 votes2 answers2387 viewsDo a custom validation on Laravel 5I have a system on Laravel 5. I have a Form Request validating the fields of a form with some rules. And here’s what I needed to do: I have a tab on the form that registers the partners of a… 
- 
		3 votes1 answer2482 viewsLaravel: route with parametersI have a school system with a call screen where there is a button that opens a modal with a form to choose the class and the date (chamadas/index). This form will redirect to a screen with the list… 
- 
		3 votes2 answers145 viewsObject property from JSON is not accessibleWell I’m working with the framework Laravel in versão 5.2 I’m developing a API where I have a Painel administrativo that produces and manages the content in the case in question produto, and I have… 
- 
		3 votes3 answers2910 viewsRoutes accessible only to users logged in to Laravel?Can someone give me a hint on how to create routes that can be accessed only by users who are authenticated, using the Laravel? For example, routes that refer to sharing, editing, deleting and… 
- 
		3 votes1 answer89 viewsDisplay data randomly from a databaseI’d like to stop displaying by date and decreasing and make it display randomly or as I know it - randomly. below the excerpt I have to modify from the php file: public function getNewReleases() {… 
- 
		3 votes2 answers674 viewsHow to use "echo" in an Laravel view?I’m hoping that in mine layout blade echo only if the variable $errors is defined: @section('mensagens') <div class="container"> <div class="row"> <div… 
- 
		3 votes1 answer6521 viewsUsing Count() in LaravelI have a controller who plays for my view the total number of courses registered in the portal. My doubt is due to the operation of the method count(). For example, the output of both instructions… 
- 
		3 votes2 answers315 viewsProblem in a foreachI’m using Laravel 5.3, and by making a foreach in the view, it does not recognize as an object, but if I print only what is in the variable $user it prints an object json. Controller: public… 
- 
		3 votes1 answer388 viewsWould it be possible to override Laravel’s with method?In parts of my application I am using the following redirect: return redirect('/painel/posts') ->with(['error' => 'Ocorreu um erro ao tentar adicionar o post!']); It would be possible in the… 
- 
		3 votes1 answer580 viewsHow to make available a package created with Composer?The json below is part of the Composer.json file of a package I created: { "name": "libspkgs/utils", "type": "library", "description": "Descrição aqui.", "keywords": ["key1", "key2"], "homepage":… 
- 
		3 votes1 answer58 viewsHow to define the semantics of downloaded packages with Composer?I created some PHP packages with the help of Composer as dependency manager and made them available in Packagist (https://packagist.org/users/fabiojaniolima/packages/). After uploading the packages… 
- 
		3 votes2 answers319 viewsForeach with PHP StdclassMy page shows posts that have been registered in the database. Some posts have files that have been uploaded. These files are saved in server folders and the database has the table "Archive" with… 
- 
		3 votes1 answer1519 viewsEdit record before passing validation rule in LaravelI own a form who registers clients. In the field of CPF, i format the data with jQuery by inserting the punctuation between the digits. It turns out that by inserting this formatting, my Requets do…