public function run() { DB::table('contacts')->truncate(); $faker = Faker\Factory::create('zh_TW'); foreach (range(1, 10) as $number) { App\Contact::create(['name' => $faker->name, 'email' => $faker->email, 'message' => $faker->paragraph, 'created_at' => Carbon\Carbon::now()->addDays($number), 'updated_at' => Carbon\Carbon::now()->addDays($number)]); } }
<?php /** * =========================================================== * Contacts */ Route::get('contacts/search', ['as' => 'admin.contacts.search', 'uses' => 'ContactsController@search']); Route::post('contacts/image/{id}', ['as' => 'admin.contacts.image', 'uses' => 'ContactsController@postImage']); Route::bind('contacts', function ($id) { return App\Contact::findOrFail($id); }); Route::resource('contacts', 'ContactsController', []);
<?php Admin::model('App\\Contact3')->title('Contact')->alias('contacts3')->display(function () { $display = AdminDisplay::table(); $display->with('country', 'companies'); $display->filters([Filter::related('country_id')->model('App\\Country')]); $display->columns([Column::image('photo')->label('Photo'), Column::string('fullName')->label('Name'), Column::datetime('birthday')->label('Birthday')->format('d.m.Y'), Column::string('country.title')->label('Country')->append(Column::filter('country_id')), Column::lists('companies.title')->label('Companies')]); return $display; })->createAndEdit(function ($id) { $display = AdminDisplay::tabbed(); $display->tabs(function () use($id) { $tabs = []; $form = AdminForm::form(); $form->items([FormItem::columns()->columns([[FormItem::text('firstName', 'First Name')->required(), FormItem::text('lastName', 'Last Name')->required(), FormItem::text('phone', 'Phone'), FormItem::text('address', 'Address')], [FormItem::image('photo', 'Photo'), FormItem::date('birthday', 'Birthday')->format('d.m.Y')], [FormItem::select('country_id', 'Country')->model('App\\Country')->display('title'), FormItem::textarea('comment', 'Comment')]])]); $tabs[] = AdminDisplay::tab($form)->label('Main Form')->active(true); if (!is_null($id)) { $instance = App\Contact::find($id); if ($instance->country_id) { $country = Admin::model('App\\Country')->fullEdit($instance->country_id); $tabs[] = AdminDisplay::tab($country)->label('Form from Related Model (Country)'); } $companies = Admin::model('App\\Company')->display(); $companies->scope('withContact', $id); $companies->parameters(['contact_id' => $id]); $tabs[] = AdminDisplay::tab($companies)->label('Display from Related Model (Companies)'); } return $tabs; }); return $display; })->delete(null);
<?php $user_stats = App\Contact::countUserStats($user); ?> <div class="box box-primary"> <div class="box-body box-profile"> <a href="http://ru.gravatar.com/"><img class="profile-user-img img-responsive img-circle" src="<?php echo $user->getProfileImage(); ?> " /></a> <h3 class="profile-username text-center">{{$user->name}}</h3> <p class="text-muted text-center">{{$user->role}}</p> <p class="text-muted text-center">Санга: {{$user->sanga}}</p> <p class="text-muted text-center">Округ: {{$user->circle}}</p> <ul class="list-group list-group-unbordered"> <li class="list-group-item"> <b>В обработке</b> <a class="pull-right" href="{{route('contact.user', $user->id)}}">{{$user_stats[\App\Contact::STATUS_WORK]}}</a> </li> <li class="list-group-item"> <b>Посещает</b> <a class="pull-right" href="{{route('contact.user', $user->id)}}">{{$user_stats[\App\Contact::STATUS_SUCCESS]}}</a> </li> </ul> </div><!-- /.box-body --> </div><!-- /.box -->
Route::get('/', function () { return view('layouts.website'); }); Route::get('/home', function () { return view('layouts.website'); }); Route::group(['middleware' => 'auth', 'prefix' => 'admin'], function () { Route::get('/', ['as' => 'admin.index', 'uses' => 'HomeController@dashboard']); /** * =========================================================== * Contacts */ Route::get('contacts/search', ['as' => 'admin.contacts.search', 'uses' => 'ContactsController@search']); Route::post('contacts/image/{id}', ['as' => 'admin.contacts.image', 'uses' => 'ContactsController@postImage']); Route::bind('contacts', function ($id) { return App\Contact::whereUserId(auth()->user()->id)->findOrFail($id); }); Route::resource('contacts', 'ContactsController', []); /** * Drivers */ Route::get('drivers/birthdays', ['as' => 'admin.drivers.birthdays', 'uses' => 'DriversController@birthdays']); Route::get('drivers/search', ['as' => 'admin.drivers.search', 'uses' => 'DriversController@search']); Route::post('drivers/image/{id}', ['as' => 'admin.drivers.image', 'uses' => 'DriversController@postImage']); Route::bind('drivers', function ($id) { return \App\Driver::findOrFail($id); }); Route::resource('drivers', 'DriversController'); /** * Todos */