| Package Data | |
|---|---|
| Maintainer Username: | rnostafa |
| Maintainer Contact: | dr.clon3r@yahoo.com (Mostafa) |
| Package Create Date: | 2017-07-09 |
| Package Last Update: | 2017-08-07 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-12-11 03:00:29 |
| Package Statistics | |
|---|---|
| Total Downloads: | 53 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 1 |
| Total Watchers: | 1 |
| Total Forks: | 0 |
| Total Open Issues: | 0 |
This package compatible with Laravel >=5
This package help you out to make model from database and set scenario for it.
Run the Composer update comand
$ composer require hqq/scenario
Or if you using phpStorm , you can use Tools > Composer > Add Dependency
In your config/app.php add hqq\scenario\ScenarioServiceProvider::class, to the end of the $providers array
'providers' => [
Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
Illuminate\Auth\AuthServiceProvider::class,
...
hqq\scenario\ScenarioServiceProvider::class,
],
php artisan make:cmodel table_name<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Units extends Model {
static $rules = [
'phone' => ['required|numeric|digits:11'],
'address' => ['required'],
'services' => ['required'],
'website' => ['required|regex:/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/'],
'email' => ['required|email',['mostafa']],
'description' => ['required',['mostafa']],
'about_us' => ['required', ['mehrdad']],
'picture' => ['required|image|mimes:jpg,png,gif,jpeg|max:1000', ['store','mostafa']]
];
protected $table = "units";
protected $fillable = ['picture', 'phone', 'address', 'services', 'website', 'email', 'description', 'about_us'];
}
Scenarioo::setRules(AllowedUnits::$rules)Scenarioo::setScenario(['store','mostafa'])Scenarioo::Rules()Scenarioo::setRules(Units::$rules);
Scenarioo::setScenario(['store','mostafa']);
$validation = \Validator::make($request->all(),Scenarioo::Rules());
if($validation->fails()){
return \Redirect::back()->withErrors($validation->errors())->withInput();
}