Esempio n. 1
0
 /**
  * Store a newly created resource in storage via ajax.
  */
 public function store(Request $request)
 {
     // Check authorisation and throw 404 if not
     if (!(Auth::user()->company->subscription && Auth::user()->is('full.access|full.read.acccess|whs.admin'))) {
         return view('errors/404');
     }
     if ($request->ajax()) {
         return SafetyTip::create($request->all());
     }
     return view('errors.404');
 }
Esempio n. 2
0
 /**
  * Migrate Tips
  */
 public function tips()
 {
     echo "<h1>Migrating Tips</h1>";
     $tips = zTip::all();
     $tips->each(function ($tip) {
         echo "<b>" . $tip->title . "</b><br>";
         $rob = User::where('username', 'boss')->first();
         $tara = User::where('username', 'anton')->first();
         switch ($tip->author) {
             case 'Robert Moerman':
                 $author = $rob->id;
                 break;
             case 'Tara Antoniolli':
                 $author = $tara->id;
                 break;
             default:
                 $author = '1';
         }
         $newTip = SafetyTip::create(array('title' => reformatOldStr($tip->title), 'body' => reformatOldStr($tip->body), 'last_published' => $tip->last_pub, 'status' => $tip->active, 'created_by' => $author, 'updated_by' => $author, 'company_id' => '3'));
     });
     echo "<h1>Completed</h1>";
 }