Add Encart settings

This commit is contained in:
Sebastien Hattry 2021-12-08 17:32:56 +01:00
parent 2249eac2b1
commit 1bee6fd514
8 changed files with 173 additions and 1 deletions

View file

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class EncartsController extends Controller
{
//
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreEncartRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UpdateEncartRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
//
];
}
}

16
app/Models/Encart.php Normal file
View file

@ -0,0 +1,16 @@
<?php
namespace App\Models;
use App\Enums\Page;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Encart extends Model
{
use HasFactory;
public $castEnums = [
'page' => Page::class
];
}

View file

@ -0,0 +1,32 @@
<?php
namespace Database\Factories;
use App\Models\Encart;
use Illuminate\Database\Eloquent\Factories\Factory;
class EncartFactory extends Factory
{
protected $model = Encart::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'title' => $this->faker->words(5),
'title' => $this->faker->words(5),
'text' => $this->faker->realText(25),
'link_label' => $this->faker->text(128),
'link' => route('wasup'),
'link_new_tab' => rand(0, 1),
'date_start' => Carbon::now(),
'date_end' => Carbon::now()->addDays(2),
'picture' => new SplFileInfo(resource_path('assets/images/image-sample.jpg'))
];
}
}

View file

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateEncartsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('encarts', function (Blueprint $table) {
$table->id();
$table->smallInteger('page');
$table->string('title');
$table->string('subtitle');
$table->string('text');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('encarts');
}
}

View file

@ -16,7 +16,8 @@ class DatabaseSeeder extends Seeder
$this->call([
UserSeeder::class,
SlidersSeeder::class
SlidersSeeder::class,
EncartsSeeder::class,
]);
}

View file

@ -0,0 +1,18 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class EncartSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
}
}