/** * Create user profile * * @param Request $data * @param type $id int */ public function createProfile($data, $id) { $profile = new Profile(); //$profile->name = $data->name; //$profile->last_name = $data->last_name; $profile->user_id = $id; $profile->city_id = $data->city; $profile->about = "about me"; $profile->save(); }
public function run() { $faker = Faker\Factory::create(); DB::table('users')->delete(); $user = User::create(['email' => '*****@*****.**', 'password' => Hash::make('123456'), 'user_name' => 'admin', 'ads_rise' => 5, 'blocked' => 0, 'balance' => 0]); foreach (range(2, 30) as $index) { $user = User::create(['email' => $faker->email, 'password' => Hash::make('1234'), 'user_name' => $faker->userName, 'ads_rise' => 5, 'blocked' => rand(0, 1), 'balance' => 0]); $city_id = Cities::orderBy(DB::raw('RAND()'))->first()->id; \ZaWeb\Profile\Models\Profile::create(['user_id' => $user->id, 'name' => $faker->firstName, 'last_name' => $faker->lastName, 'about' => $faker->sentence(10), 'city_id' => $city_id]); } }
public function run() { // DB::table('profiles')->delete(); \ZaWeb\Profile\Models\Profile::create(array('user_id' => 1, 'name' => 'Василий', 'last_name' => 'Иванов', 'about' => 'Site admin', 'city_id' => 1)); }
}); $router->bind('ads', function ($id) { return \App\Models\Advertisement::find($id); }); $router->bind('country', function ($title) { return \App\Models\Country::where('title', '=', $title)->first(); }); /** * PROFILE */ $router->bind('profile', function ($user_name) { $user = \App\Models\User::where('user_name', $user_name)->first(); if (!$user) { $user = \App\Models\User::where('user_name', Auth::user()->user_name)->first(); } return \ZaWeb\Profile\Models\Profile::where('user_id', $user->id)->first(); }); /** * COMMENTS */ Route::model('comments', 'App\\Models\\Comments'); //-> Route::resource('comments', 'CommentsController'); //-> $router->bind('comments', function ($ads_id) { return \App\Models\Comments::where('ads_id', 21)->first(); }); /** * Services */ Route::resource('services', 'ServicesController');
public function index(Profile $profile) { return \ProfileService::viewProfile(Profile::with('user')->with('city')->with('advertisements')->with('avatar')->where('user_id', Auth::user()->id)->first()); }