Categories
Laravel

How to execute PHP code from the command line?

Simple just type

php -a

More info about php :

Categories
Laravel SqLite

SQLITE – Auto-increment a column with Laravel

Example : for SQLITE the double quote is critical to make it work

Polls::updateOrInsert(['business_id'=> $business_id],
    [
        "$vote_value" => DB::raw('"$vote_value" + 1'),
        'polls_name' => $theBusiness->BUSINESSNAME,
        'source' => env('APP_CODE'),
        'updated_at' => $lastupdated
    ]);
Categories
Laravel

Laravel Eloquent SQL query compare insensitive string

'ilike' or 'not ilike'
return $query->where('api_call', 'not ilike', '%TEST%');
Categories
Laravel

Install Css Flag with Laravel

#1 – Install Flag library via NPM

npm install flag-icon-css

#2 – Import css to your library

 import 'flag-icon-css/css/flag-icon.css'

#3 – in your blade

<li >
    <a href="/en"> <i class=" flag-icon flag-icon-us"></i></a>
</li>
Categories
Laravel

Laravel : php artisan migrate specific file

use this command php artisan migrate --path=/database/migrations/my_migration.php 

Categories
Laravel

Laravel Nova – Quickstart Postgres

Quick resource + model generator

php artisan nova:resource Businesses 
php artisan make:model Businesses

Model Example : Thetable

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Thetable extends Model
{

    protected $connection = 'pgsql-api';
    protected $table = 'mapi_admin_tool.THETABLE';
    
    protected $primaryKey = 'id';

    protected $dateFormat = 'Y-m-d H:i:sO';


   public function __construct(array $attributes = [])
   {
     parent::__construct($attributes);
   }

    protected $dates = [
     'created_at',
     'updated_at',
     'deleted_at'
   ];
}

Nova Resource Example

<?php

namespace App\Nova;

use Illuminate\Http\Request;
use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class Thetable extends Resource
{
    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = 'App\M2TrackFileSubmissionToWindsurfer';

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'id';

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'id',
    ];

    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            ID::make('id')->sortable(),
            Text::make('file_uuid')->sortable(),
            Text::make('set_uuid')->sortable(),
            Text::make('windsurfer_job_id')->sortable(),
            Text::make('cust_filename')->sortable(),
            Text::make('artwork_info')->sortable(),
            Date::make('created_at')->sortable(),
            Date::make('update_at')->sortable(),
        ];
    }
Categories
General Laravel

Laravel – Versionning your app.js

LIFE SAVER for frontend beginner developer!

Laravel – Versionning your app.js to cache bust for deploying

1 – Modify following file webpack.mix.js

mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css').version();

mix.version();

2 – Modify your blade

<script src="{{ env('APP_URL') }}{{ mix('js/app.js') }}"></script>

3 – you will see the following generation

<script src="https://xxxxx.raleche.com.test/js/app.js?id=a8305a8c81a6359c3c7b"></script>





#1 – Make sure the composer.json looks like this

"require": {
   "php": "^7.2",
   "fideloper/proxy": "^4.0",
   "laravel/framework": "^8.0",
   "laravel/passport": "^10.0",
   "laravel/socialite": "^5.0",
   "laravel/tinker": "^2.0",
   "laravel/ui": "^3.0",
   "predis/predis": "^1.1"
},
"require-dev": {
   "facade/ignition": "^2.3.6",
   "mockery/mockery": "^1.0",
   "nunomaduro/collision": "^5.0",
   "phpunit/phpunit": "^9"
}

#2 – if you see following issue

laravel/framework replaces illuminate/support and thus cannot coexist with it.

Remove remove illuminate/support

composer remove illuminate/support

#3 – The report, render, shouldReport, and renderForConsole methods of your application’s App\Exceptions\Handler class should accept instances of the Throwable interface instead of Exception instances: Change app/Exceptions/Handler.php as follow

<?php

namespace App\Exceptions;

use Throwable;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
   /**
    * A list of the exception types that are not reported.
    *
    * @var array
    */
   protected $dontReport = [
       //
   ];

   /**
    * A list of the inputs that are never flashed for validation exceptions.
    *
    * @var array
    */
   protected $dontFlash = [
       'password',
       'password_confirmation',
   ];

   /**
    * Report or log an exception.
    *
    * @param  \Throwable  $exception
    * @return void
    */
   public function report(Throwable $exception)
   {
       parent::report($exception);
   }

   /**
    * Render an exception into an HTTP response.
    *
    * @param  \Illuminate\Http\Request  $request
    * @param  \Throwable  $exception
    * @return \Illuminate\Http\Response
    */
   public function render($request, Throwable $exception)
   {
       return parent::render($request, $exception);
   }
}

Helper additional issue

php artisan config:clear
php artisan key:generate
php artisan config:clear
Categories
Laravel

Laravel Socialite

Laravel Socialite makes the experience painless and fast to implement. I highly recommend this package for quick development ! Here

laravel socialite raleche
laravel socialite raleche