Laravel eloquent relationships


In laravel you can define all kind of relationships between database tables on the model itself (as in laravel, model is representation of database table), so here's list of eloquent relationships that you can use in laravel model.

Insert using DB table doesnt update timestamp


In laravel there are two ways to insert data/record, using DB table or using model, but i found a problem when inserting the data using DB table, the timestamp created_at and updated_at is showing '0000-00-00 00:00:00' as value.

How to update timestamp in Laravel


In laravel usually you have created_at and updated_at field in your database table, these are timestamps() that you define in your laravel migration, the question is how to update the value of these timestamp specially the updated_at?

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 do raw query in Laravel


Besides the standard methods for database query that are available on laravel, you also have an option to do raw query, in this article i will show you how to do raw database query in laravel.

php artisan migrate command in Laravel


The 'php artisan migrate' command lets you run the database migration on your application, but there is more than that, there are other variant of this command that you can use such as rollback, reset, refresh, status, install and so on.

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.

Laravel 4.2 schema table column types


These are list of schema table column types that you can use when creating database migration on laravel 4.2, most of these column types also available on laravel 5, this post is just for quick reference.

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.

Looping in Laravel blade template


Just like the 'if' statement, blade also has it's own way of doing loops/looping, you can do 'for' loops, 'foreach', 'forelse', and also 'while' loops. Let's take a look at the syntax.

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 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.

Choosing the best text editor for Laravel


There are many choices when it comes to text editor for developing laravel application (or php in general), some people might prefer phpstorm, others suggest sublime text, which one is better?

Changes from Laravel 4 to Laravel 5


Laravel 5 started life as Laravel 4.3, but was promoted to its own major version when it became apparent that this new version was going to be a radical departure from version 4 of the framework.

How to change be right back message on Laravel


When your application is on maintenance mode, it will display 'be right back' message, what if you want to change this message? how to change this 'be right back' message on laravel?

How to put Laravel in maintenance mode


Did you know that you can put laravel on maintenance mode? this is another cool feature on laravel, you can put your application in maintenance mode temporarily and then you can put it back on again in no time.

Laravel 5.2 directory structure


Laravel 5 have completely different directory structure than laravel 4, so if you want to switch your application to laravel 5, you can start by learning the directory structure first. In this article i will show directory structure in laravel 5.2, but it should be compatible with other version of laravel 5.

How to get table prefix in Laravel 4.2


On your database configuration (app/config/database.php), you can specify a prefix for every table that you use on your database, the question is how to get this table prefix dynamically without making it hardcoded.

How to query single record in Laravel Eloquent


The get() method in laravel eloquent will return more than one records, which is good if you really want to do that, but what if you only need one record, how to query a single record in laravel eloquent?

How to do query with Laravel Eloquent


In laravel you can do query to the database using the eloquent ORM (Object Relational Mapping), using eloquent you can create a nice looking and easy to understand database query.

How to do multi language on Laravel 4.2


You might need to add multi language system on your application, and with laravel, multi language is something easy to do, that's one of the benefit of using this framework, in this tutorial i will show you how to create a multi language system on laravel 4.2.

How to create hashed password in Laravel 4.2


You need to do encryption when you want to store/save password on your application, in laravel 4.2 you can use the hashing technique to save and also checking the password, in this article i will show you how to do that.

Postman is your best friend


If you are working on creating back-end API with laravel, you will need tool such as 'postman' to test your APIs, using postman you can test your API easier than calling directly from front-end app, having postman helps developer works faster and easier.

Laravel 4.2 directory structure


When you first learn about laravel you need to understand the directory structure of laravel, this article i will explain little bit about directory structure in laravel 4.2, this tutorial is for beginners learning about laravel 4.2.

How to create artisan command in Laravel 4.2


There will be times when you need to create your own artisan command, and it is totally possible with laravel, you can create your own artisan command, in this tutorial i will show you how to create artisan command on laravel 4.2.

How to change Whoops, looks like something went wrong error message in Laravel 4.2


'Whoops, looks like something went wrong', is the dafault error message from laravel, if you turn off the debugging option in laravel. You will not get this message when error happens and the debugging mode on laravel is set enable.

How to enable and disable Debug mode on Laravel 4.2


One of the cool feature on laravel is that it has debug mode, when you are on development stage, it is always a good idea to enable debugging mode on laravel, later on production stage you can disable the debug mode.

Error in exception handler Laravel 4.2


'Error in exception handler.' is the common error message that you get when setting up laravel project for the first time. The question is how to solve this issue? how to fix it?

Category

Category