iampraveenak-blog
akTips
10 posts
Don't wanna be here? Send us removal request.
iampraveenak-blog · 4 years ago
Link
TaskRabbit Clone is a readymade script that covers both sides of an on-demand market place. Portals that connects both the service provider and the one who seeks the service.
0 notes
iampraveenak-blog · 6 years ago
Link
0 notes
iampraveenak-blog · 6 years ago
Text
Resources in Laravel routes
#laravel #php #waioz #akTips #tipsoftheday #tips #tricks #laravel_tips #day13
Call Route::resource() instead of Route::get(), Route::post(), Route::patch(), Route::put(), Route::delete() in your routes file. Lets see how it’s working
Generate the controller using command line
php artisan controller:make UsersController
Within this generated controller, each function will correspond to one of the routes below.
For examples, /users will map to the index method of UsersController, /users/create will map to create, etc.
Route::resource('users', 'UsersController');
This code helps to avoid eight routes
GET /users
GET /users/:id
GET /users/create
GET /users/:id/edit
POST /users
PUT /users/:id
PATCH /users/:id
DELETE /users/:id
Now we have the necessary power to build RESTful applications and APIs with easily.
https://waioz.com
0 notes
iampraveenak-blog · 6 years ago
Link
0 notes
iampraveenak-blog · 6 years ago
Text
Minify and combine css and javascript
Minifying Javascript files and CSS files are extremely important in the performance of your site. This reduces the requests processed from the website. So it reduces the request speed of your application. Here is the library for laravel, I have used to combine and minify the files.
Packer — https://github.com/eusonlito/lar...
Packer library will automatically combine, minify and create static files in folder.
Example: If you include 20 different css files in layout this will combine them to single file.
#laravel #php #waioz #akTips #tipsoftheday #tips #tricks #laravel_tips #day11
https://aktips.quora.com/Minify-and-combine-css-and-javascript
0 notes
iampraveenak-blog · 6 years ago
Text
Eager Loading in Laravel
The best way to approach eager loading to implement queries is buy using the eloquent model on laravel. It uses a “Lazy Loading” approach.
Lazy Loading
Optimize your PHP code for Eager Loading with Laravel Eloquent Queries. Object Relational mapping (ORM) makes working with databases amazingly simple. While defining database relationships in an object-oriented way, the query related model data are made easy for developers, as developers might not pay attention to the underlying database calls.
$users = App\User::all(); // 10 records in a table foreach($users as $user){ echo $user->profile->facebook_image; }
For every user in database, the eloquent runs a separate SQL query (11 queries instead of 1).
$users = App\User::with(‘profile)->get(); foreach($users as $user){ echo $user->profile->facebook_image; }
Eager load query will run only one SQL query with JOIN.
Don’t use db query in laravel, Instead of db query use eloquent, It is the best practice to your application.
#laravel #php #waioz #akTips #tipsoftheday #tips #tricks #laravel_tips #day10
https://aktips.quora.com/Eager-Loading-in-Laravel
0 notes
iampraveenak-blog · 6 years ago
Text
Artisan commands in Laravel
Laravel artisan commands are used to boost application performance.
php artisan config:cache php artisan route:cache php artisan optimize — force
Commands are useful when you look to change the code in many routes and configuration files. Don’t forget to clear cache after changes.
php artisan config:clear php artisan route:cache php artisan view:clear
#laravel #php #waioz #akTips #tipsoftheday #tips #tricks #laravel_tips #day9
https://aktips.quora.com/Artisan-commands-in-Laravel
0 notes
iampraveenak-blog · 6 years ago
Text
Route Patterns in Laravel
Route Patterns in Laravel
Laravel has some amazing route patterns that are used to optimize the laravel code. Undefined routes.php page automatically goes to 404 page is a common knowledge. The 404 page usually occurs with an undefined, unstructured URLs with incorrect parameters. If the given parameter is set as an integer and say the parameter is inputted as string, it will redirect to 404 page.
We can essentially check the parameter type by using where() route pattern. Basically those validations are written in controllers, but having it written in the routes file will optimize your code.
Route::get('user/{name}', function ($name) {  // Only executed if {name} is a slug alphanum (length between 2 and 32) })->where('name', '[A-Za-z0-9]{2,32}');
Route::get('user/{id}', 'UserController@getUser')->where('id', '[0-9]+'); // Only executed if {id} is a slug numeric
Route::get('user/{id}/{name}', function ($id, $name) {   // Only executed if {id} is numeric and {name} is alphanum (length between 2 and 32) })->where(['id' => '[0-9]+', 'name' => '[A-Za-z0-9]{2,32}']);
#laravel #php #waioz #akTips #tipsoftheday #tips #tricks #laravel_tips #day8
0 notes
iampraveenak-blog · 6 years ago
Text
Chunk() method in Laravel
Chunk method is very powerful to process bigger database collection.
Instead of,
$users=User::get(); foreach($users as $user) { … }
You can use
User::chunk(100,function($users){ foreach($users as $user) { … } });
Originally published at aktips.quora.com.
0 notes
iampraveenak-blog · 6 years ago
Text
Replicate in Laravel Eloquent Model
Replicate is used to make a copy of a row. It’s a simple one, here’s the way to make a copy of database row
$order = Order::find($order_id); $newOrder = $order->replicate(); $newOrder->save();
You can also update the fields like
$order = Order::find($order_id); $newOrder = $order->replicate(); $newOrder->created_at=time(); $newOrder->currency='USD; $newOrder->save();
https://aktips.quora.com/Replicate-in-Laravel-Eloquent-Model
1 note · View note