示例#1
0
 /**
  * @param $data
  * @return static
  */
 public function saveOrganisation($data)
 {
     $organisation = Organisation::firstOrNew(['name' => $data['organisation_name']]);
     $organisation->type = 1;
     $organisation->description = $data['organisation_description'];
     $organisation->save();
     return $organisation;
 }
示例#2
0
 /**
  * Show the home page.
  *
  * @return \View
  */
 public function index()
 {
     $this->setTitle('Home');
     $this->setLayout('blank', 'home');
     $this->asset()->add('home-style', 'assets/css/home.css', ['theme']);
     $this->asset()->container('footer')->add('uk-grid', 'assets/library/uikit/js/components/grid.js', ['uikit']);
     return $this->render('home', ['featured_clients' => Organisation::all()->take(4)]);
 }
示例#3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $user = Auth::getUser();
     $input = Request::all();
     $org = Organisation::create($input);
     $result = DB::table('organisation_user')->insertGetId(array('organisation_id' => $org->id, 'user_id' => $user->id, 'owner_id' => true));
     //return redirect('/dashboard/' . $org->id);
     return redirect('/dashboard/');
 }
 public function run()
 {
     DB::table('organisations')->truncate();
     foreach (static::$organisations as $code => $org) {
         $org = Organisation::forceCreate($org);
         $org->slug = str_slug($org->name);
         $org->save();
     }
 }
示例#5
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $organisation = Organisation::create(['name' => $data['organisationName']]);
     $role = Role::whereName('owner')->first();
     $userOrganisationRole = new UserOrganisationRole(['user_id' => $user->id, 'organisation_id' => $organisation->id, 'role_id' => $role->id]);
     $user->organisationRoles()->save($userOrganisationRole);
     return $user;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @param Request $request
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, Request $request)
 {
     $org = Organisation::findOrFail($id);
     if ($request->user()->isSuperAdmin()) {
         //If has Photo
         if (!is_null($org->photo)) {
             $photo = $org->photo;
             $file = public_path('images/') . $photo->url;
             if (File::exists($file)) {
                 // Delete from Storage
                 File::delete($file);
                 $org->photo_id = null;
                 $org->save();
                 $photo->delete();
             }
         }
         $org->delete();
         return back()->withNotification("Organisation Deleted!")->withType('success');
     }
     return back()->withNotification("Sorry! You are not authorized.")->withType('danger');
 }