Veronica  Roob

Veronica Roob

1648990860

Laravel Zero: A PHP Framework for Console Artisans

This is a community project and not an official Laravel one

Laravel Zero was created by Nuno Maduro and Owen Voke, and is a micro-framework that provides an elegant starting point for your console application. It is an unofficial and customized version of Laravel optimized for building command-line applications.


Documentation

For full documentation, visit laravel-zero.com.

Support the development

Do you like this project? Support it by donating

License

Laravel Zero is an open-source software licensed under the MIT license.

Author: laravel-zero
Source Code: https://github.com/laravel-zero/laravel-zero

#php #laravel 

What is GEEK

Buddha Community

Laravel Zero: A PHP Framework for Console Artisans

Laravel Vs CodeIgniter (Choosing Best PHP Framework In 2021)

This is image title

Do you want to create an outstanding web application? You would need a flexible and scalable framework in terms of architecture. Laravel and CodeIgniter have gained a lot of popularity in the last few years. Both frameworks can use to create robust and high-performance web apps. Laravel powers around 0.37% of the websites while CodeIgniter holds 0.36% of the market share.

This is image title

Laravel, being a popular open-source PHP framework, is widely used for building websites and web applications. As this framework uses the MVC pattern, it provides comfortable and easy development. One gets complete control over the project over the development of applications as external APIs can be implemented. Laravel’s MVC architecture reuses the application logic to create scalable web apps.

On the other hand, CodeIgniter is an object-oriented, event-driven functional framework that helps to create fully-featured web applications. It considers as one of the best frameworks to develop dynamic websites and web apps. As the users do not need to rely on MVC development patterns, it can be integrated with third-party plugins to add complex features to the web app. CodeIgniter is known for its amazing security.

1. Built-In Modules
Laravel allows web developers to break the project into smaller modules through a bundle. They can re-use the models across different projects and save development costs.CodeIgniter does not support built-in modules and the programmers need to create and maintain multiple modules with the help of Modular Extension.

2. Library Usage
Laravel possesses object-oriented libraries that used to add the right features. Laravel libraries are comparatively easier to use than the ones available for CodeIgniter.

3. REST APIs
Laravel offers RESTful controllers to help the developers create custom REST APIs without writing any additional code. CodeIgniter does not provide such a feature to simplify the development of APIs. CodeIgniter developers may have to write more code as compared to Laravel developers while creating web apps.

4. HTTPS Support
Laravel supports the HTTPS route and helps programmers to make the right decision for creating a specific URL for each HTTPS route. With CodeIgniter development, programmers need to manage URL helpers to enable protection for data transmission.

5. Data Migration
Laravel provides greater support for data migration while CodeIgniter may have limitations and it may be time-consuming to migrate data while using it.database migration
This is image title

6. PHP Version Support
Both Laravel and CodeIgniter frameworks support the latest PHP version i.e. PHP 7.X. The developers and testers may find it easy to build web apps with Laravel as compared to CodeIgniter development.

7. Technical Documentation
When we talk about the technical documentation for both frameworks, CodeIgniter wins the race as it has easy-to-understand documentation. On the other hand, Laravel has tough documentation that may not be easy to understand for all programmers.

Read More

#laravel or codeigniter #laravel vs codeigniter #laravel vs codeigniter performance #php framework laravel vs codeigniter #php laravel vs codeigniter

Seamus  Quitzon

Seamus Quitzon

1595201363

Php how to delete multiple rows through checkbox using ajax in laravel

First thing, we will need a table and i am creating products table for this example. So run the following query to create table.

CREATE TABLE `products` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
 `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
 `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
 `updated_at` datetime DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Next, we will need to insert some dummy records in this table that will be deleted.

INSERT INTO `products` (`name`, `description`) VALUES

('Test product 1', 'Product description example1'),

('Test product 2', 'Product description example2'),

('Test product 3', 'Product description example3'),

('Test product 4', 'Product description example4'),

('Test product 5', 'Product description example5');

Now we are redy to create a model corresponding to this products table. Here we will create Product model. So let’s create a model file Product.php file under app directory and put the code below.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = [
        'name','description'
    ];
}

Step 2: Create Route

Now, in this second step we will create some routes to handle the request for this example. So opeen routes/web.php file and copy the routes as given below.

routes/web.php

Route::get('product', 'ProductController@index');
Route::delete('product/{id}', ['as'=>'product.destroy','uses'=>'ProductController@destroy']);
Route::delete('delete-multiple-product', ['as'=>'product.multiple-delete','uses'=>'ProductController@deleteMultiple']);

#laravel #delete multiple rows in laravel using ajax #laravel ajax delete #laravel ajax multiple checkbox delete #laravel delete multiple rows #laravel delete records using ajax #laravel multiple checkbox delete rows #laravel multiple delete

Seamus  Quitzon

Seamus Quitzon

1595212560

5 Laravel’s Hidden Gems

1. Stop on first validation error

By default, Laravel will check for all validation rules and return a list of errors. But if you want to stop this process after first validation failure, that’s how you can achieve it

$request->validate([
    'title' => 'bail|required|unique:posts|max:255',
    'body' => 'required',
]);

2. Find many

Most of us developers have used Eloquent’s method find to search for one specific id, but do you know we can pass multiple ids to find which will return a collection.

// Will return Eloquent Model
$user = User::find(1);
// Will return Eloquent Collection
$users = User::find([1,2,3]);

3. Relationship but with condition

Some times we need to apply where on relationships, instead of calling relationship and then chaining where we can achieve it by following:

// app/Post.php model
public function comments()
{
    return $this->hasMany(Comment::class);
}
public function approved_comments()
{
    return $this->hasMany(Comment::class)->where('approved', 1);
}

4. Rename pivotal table

In pivot table, if you want to rename pivot to some thing else, this can be done by following code:

public function podcasts() {
return $this->belongsToMany('App\Podcast')
->as('subscription')
->withTimestamps();
}
// Then somewhere in Controller...
$podcasts = $user->podcasts();
foreach ($podcasts as $podcast) {
// instead of $podcast->pivot->created_at ...
echo $podcast->subscription->created_at;
}

#laravel #php #find many laravel #prepare for validation laravel #relationship but with condition laravel #rename pivotal table laravel #stop on first validation error laravel

Eleo Nona

Eleo Nona

1598256222

How to Install Laravel PHP Framework with Nginx on Ubuntu 20.04

Laravel is the most popular, free, and open-source PHP framework in the world, known for its expressive and elegant syntax. Laravel is accessible, powerful, and offers some of the best web development tools required for large, robust, and modern applications.

In this article, you will learn how to install the Laravel PHP Framework on Ubuntu 20.04 server running on the Nginx web server.

Prerequisites

Step 1: Installing Required PHP Modules

After setting up the LEMP stack on your Ubuntu 20.04 server as described in the guide in the link above, you need to install additional PHP extensions required by Laravel as follows:

$ sudo apt update
$ sudo apt php-common php-json php-mbstring php-zip php-xml php-tokenizer

Install PHP Modules in Ubuntu

Install PHP Modules in Ubuntu

#laravel #ubuntu #laravel php framework #php

Seamus  Quitzon

Seamus Quitzon

1595216280

Some of the most frequent how tos in Laravel

How to get relationship from relationship using With() in Laravel

Some times there are cases where you want to get relationship from relationship in Laravel, that can be achieved via following:

Account::with(['profiles','profiles.products'])->get();

How to create multiple where clauses in single where clause in Laravel

Sometimes you want to apply multiple where clauses in a single query like that:

$results = User::where('this', '=', 1)
    ->where('that', '=', 1)
    ->where('this_too', '=', 1)
    ->where('that_too', '=', 1)
    ->where('this_as_well', '=', 1)
    ->where('that_as_well', '=', 1)
    ->where('this_one_too', '=', 1)
    ->where('that_one_too', '=', 1)
    ->where('this_one_as_well', '=', 1)
    ->where('that_one_as_well', '=', 1)
    ->get();

This can be achieved using single where clause by following code:

$query->where([
    ['column_1', '=', 'value_1'],
    ['column_2', '<>', 'value_2'],
    [COLUMN, OPERATOR, VALUE]
])

How to get last inserted id in Laravel

The are situations, during bulk insertion or single row insertion you may want to retrieve last inserted id, can be achieved by following:

$post = Input::All();

    $data = new Company;
    $data->nombre = $post['name'];
    $data->direccion = $post['address'];
    $data->telefono = $post['phone'];
    $data->email = $post['email'];
    $data->giro = $post['type'];
    $data->fecha_registro = date("Y-m-d H:i:s");
    $data->fecha_modificacion = date("Y-m-d H:i:s");
   $data->save();
   //getting last inserted id
   $data->id;

How to add a custom attribute in Laravel during Model load

Sometimes you want to add a custom attribute in model during load, this can be achieved by following code:

class Book extends Eloquent {

    protected $table = 'books';

    public function toArray()
    {
        $array = parent::toArray();
        $array['upper'] = $this->upper;
        return $array;
    }

    public function getUpperAttribute()
    {
        return strtoupper($this->title);    
    }

}

#laravel #php #how to add a custom attribute in laravel during model load #how to create multiple where clauses in single where clause in laravel #how to get a specific column using with() in laravel #how to get last inserted id in laravel #how to get relationship from relationship laravel #laravelfaq