PHP code example of halestar / laravel-drop-in-cms
1. Go to this page and download the library: Download halestar/laravel-drop-in-cms 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/ */
class SitePolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user = null): bool
{
return true;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user = null, Site $site = null): bool
{
return true;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user = null): bool
{
return true;
}
...
class MySitePolicy extends \halestar\LaravelDropInCms\Policies\SitePolicy
{
public function create(User $user = null): bool
{
return $user->can('create sites');
}
}
// This will actually generate a backup instance. So long as
// this object persist in memory, you have a snapshot of your
// database at the time this command is executed.
$backup = new SystemBackup();
// to access the backup data, get it by doing:
$backupData = $backup->getBackupData();
// $backupData now has a string containing all the information
// in your database
public function cleanUpDb()
{
// save the cms data.
$cmsSave = new SystemBackup();
$cmsData = $cmsSave->getBackupData();
// refresh the db, and seed it since it will probably have demo data
$this->call('migrate:fresh', ['--seed' => true]);
// restore the CMS data
$cmsSave->restore($cmsData);
// Optimize some stuff
$this->call('optimize:clear');
$this->call('optimize');
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.