Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cmsrs/laracms

Installation cmsRS
https://github.com/cmsrs/laracms

cms gallery-images laravel laravel-package shop

Last synced: 11 days ago
JSON representation

Installation cmsRS

Awesome Lists containing this project

README

        

# INSTALLATION

```bash
composer require cmsrs/laracms

php artisan vendor:publish --provider="Cmsrs\Laracms\Providers\LaracmsProvider" --force

php artisan migrate

php artisan db:seed
```

Remove lines from file: ./routes/web.php:
```php
//Route::get('/', function () {
// return view('welcome');
//});
```


Configure jwtAuth (in nutshell):

```bash
php artisan vendor:publish --provider="PHPOpenSourceSaver\JWTAuth\Providers\LaravelServiceProvider"

php artisan jwt:secret
```

in config/auth.php change to:

```php
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],

'guards' => [
'api' => [
'driver' => 'jwt', //'token',
'provider' => 'users',
'hash' => false
],
'web' => [
'driver' => 'session',
'provider' => 'users',
],
],

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

add User.php file in: app/Models:

```php
'admin',
'client' => 'client'
];

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password' , 'role'
];

/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];

/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier()
{
return $this->getKey();
}
/**
* Return a key value array, containing any custom claims to be added to the JWT.
*
* @return array
*/
public function getJWTCustomClaims()
{
return [];
}

public function setPasswordAttribute($password)
{
if (!empty($password)) {
$this->attributes['password'] = Hash::make($password);

}
}

static public function getTokenForClient()
{
$user = Auth::user();
if( empty($user) ){
throw new \Exception("User not auth");
}

return $user->getTokenClient();
}

public function getTokenClient()
{
$appKey = env('APP_KEY');
if( empty($appKey) ){
throw new \Exception("empty APP_KEY in config file");
}

return sha1($this->email."_".$this->id."_".$appKey);
}

public function checkClientByToken($token)
{
$expectedToken = $this->getTokenClient();
if($expectedToken == $token){
return true;
}
return false;
}

static public function checkApiClientByToken($token)
{
$user = Auth::user();
if( empty($user) ){
throw new \Exception("User not auth - for check");
}
if( !$user->checkClientByToken($token) ){
throw new \Exception("User not valid - check");
}
return true;
}

}
```

```bash
php artisan serve
```

# MANAGMENT

* go to the website http://127.0.0.1:8000/admin/

log in as:

username: [email protected]

password: cmsrs123

* create main page (page type: main_page)

* add menu

* add pages