PHP code example of pwweb / laravel-core

1. Go to this page and download the library: Download pwweb/laravel-core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pwweb / laravel-core example snippets




return [
    'models' => [
        'user' => Namespace\Of\My\User::class,
        ...
    ]
];



return [
    ...
    'locale' => 'en-GB',
    'fallback_locale' => 'en-GB',
    ...
];


'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => \PWWEB\Core\Models\User::class,
    ],
],


// Add the following lines.
use PWWEB\Core\Models\User;
use PWWEB\Core\Models\Person;

// Change the following two functions.
protected function validator(array $data)
{
    return Validator::make(
        $data,
        [
            'name' => ['rotected function create(array $data)
{
    $person = Person::create(
        [
            'name' => $data['name'],
            'surname' => $data['surname'],
        ]
    );

    $user = new User(
        [
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]
    );
    $user->person()->associate($person);
    $user->save();

    $user->assignRole('user');

    return $user;
}



namespace Path\To;

use Illuminate\Database\Eloquent\Model;
use PWWEB\Core\Traits\HasAddresses;

class MyModel extends Model
{
    use HasAddresses;
}


@date(Carbon\Carbon $date, string $format)


@menu(string $environmentSlug, string $rootNodeSlug)


use PWWEB\Core\Jobs\UpdateExchangeRates;
//...
$schedule->job(new UpdateExchangeRates, 'target_queue')->timezone('Europe/Paris')->dailyAt('16:30');
//...
bash
 ErrorException  : Trying to access array offset on value of type null

  at /var/www/vendor/pwweb/core/src/CoreServiceProvider.php:107
    103|     protected function registerModelBindings()
    104|     {
    105|         $config = $this->app->config['core.models'];
    106|
  > 107|         $this->app->bind(CountryContract::class, $config['country']);
    108|         $this->app->bind(LanguageContract::class, $config['language']);
    109|         $this->app->bind(CurrencyContract::class, $config['currency']);
    110|     }
    111|

  Exception trace:

  1   Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Trying to access array offset on value of type null", "/var/www/vendor/pwweb/core/src/CoreServiceProvider.php", [])
      /var/www/vendor/pwweb/core/src/CoreServiceProvider.php:107

  2   PWWeb\Localisation\CoreServiceProvider::registerModelBindings()
      /var/www/vendor/pwweb/core/src/CoreServiceProvider.php:81

  Please use the argument -v to see more details.