Showing posts with label how to. Show all posts
Showing posts with label how to. Show all posts

How to add primary key to Laravel model?


If you did not specify primary key in your model, laravel will assume the primary key of the table is 'id', so for example your primary key is not 'id', but let's say 'user_id' or 'employee_id' etc, how to define this in the model?

How to insert, update and delete in Laravel


If you are just learning about laravel, meaning you are beginner of laravel, you probably want to know about how to do insert, update and delete record of a database table in laravel. If you are beginner this short tutorial is for you.

How to get raw SQL query in Laravel


Using eloquent in laravel is very convenient, but sometimes you want to know the raw SQL query that's executed behind the scene, so how to get raw SQL query from laravel eloquent?

How to do insert using DB table in Laravel

How to do insert using DB table in Laravel

In laravel you can insert data to a table in two ways, the first one and the most common is using a model, create a model for that table and then insert the data, the second way is using DB::table(), in this article i will show you how to insert to database table using DB::table().

How to add and drop indexes in Laravel schema builder


On your laravel database migration you can define indexes for each table that you create, for example you can add primary key, unique value, or just a basic index. All can be done in laravel schema builder.

How to check table column exist or not in Laravel


Besides the 'hasTable' static method, you also have 'hasColumn' method which can check column exist or not on database table of laravel.

How to check table exist or not in Laravel


Is it possible to check existence of database table in laravel code? the answer is yes, it is possible to check whether a table already exist or not in laravel.

How to exit from php artisan tinker


Some people having difficulty closing/exit from artisan tinker mode, this is also happened to me when i use artisan tinker for the first time, i don't know how to close it.

Interact with your application using artisan tinker


Another cool feature in laravel is the ability to interact with your application via artisan tinker, using artisan tinker you can execute php code and interact with your application code.

How to check Eloquent get() and first() query result


Every time you run query to the database whether using eloquent get() or first() method, it's always a good idea to check the result of the query before doing other things, make sure the result is as we expected and not returning empty.

How to create table seeder in Laravel 4.2


Seeding is the technique of filling our database with sample data so we can test and create our applications. It really does make building applications much easier.

Echoing data with default value in Laravel blade


When echoing data in laravel blade template using double or triple curly braces, you don't need to worry if the value is empty, it will not displayed as an error, but sometimes you want to put a default value if the data is empty.

How to escape output in Laravel blade


When you use the blade template in laravel, specially laravel version 4, if you use the double curly braces to output something, then you are vulnerable to XSS exploits, you need to escape the output.

How to create resource controller in Laravel 4.2


Laravel 4.2 have predefined resource controller that you can use to start develop CRUD (Create, Read, Update, Delete) based application quickly.

How to pass variable to Laravel view


Passing parameter/variable to the view in laravel is something easy to do, in this article i will show you how to pass parameter/variable to the view in laravel.

How to pass parameter to Laravel route


In laravel you can pass parameter into the route, the parameter can be pass down to the controller or even the view, you can also add constraint to filter the parameter, pretty cool huh?

How to create named route in Laravel


Another cool feature on laravel is route alias or naming route, using named route you can specify a name for your route, so it is easier for you to maintain the routes, i guess.

How to show list of routes in Laravel


When your laravel application gets bigger, you will end-up having a lot of routes, and it's difficult to maintain, the ability to show list of routes probably will help you little bit to maintain the routes.

Category

Category