/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $project = new Project();
     if (Project::first()) {
         $project_id = Project::orderBy('id', 'desc')->first()->id;
         $project_id++;
     } else {
         $project_id = 1;
     }
     $project->project_name = $request->project_name;
     $project->project_desc = $request->project_desc;
     $project->project_catagory = $request->project_catagory;
     $project->project_info = $request->project_info;
     $project->project_slug = rtrim(preg_replace('/[^a-z0-9]+/i', '-', strtolower(strip_tags($request->project_name))), "-");
     if ($request->light_img == "on") {
         $project->is_light_img = true;
     }
     if ($request->hasFile('cover_img')) {
         $cover_img = $request->file('cover_img');
         $file_ext = $cover_img->guessExtension();
         $fileName = $project_id . "-cover." . $file_ext;
         $cover_img->move('upload', $fileName);
     }
     if ($request->hasFile('all_img')) {
         $files = $request->file('all_img');
         $file_count = 0;
         foreach ($files as $ind_file) {
             $file_count++;
             $file_ext = $ind_file->guessExtension();
             $fileName = $project_id . "-" . $file_count . "." . $file_ext;
             $ind_file->move('upload', $fileName);
         }
     }
     $project->photo_count = $file_count;
     $project->save();
     return redirect('/portfolio/' . $project->project_slug);
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tasks')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'description' => 'buy paint', 'due_date' => Carbon\Carbon::now()->toDateTimeString(), 'completed' => 0, 'project_id' => \App\Project::first()->id]);
     DB::table('tasks')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'description' => 'buy brushes', 'due_date' => Carbon\Carbon::now()->toDateTimeString(), 'completed' => 1, 'project_id' => \App\Project::first()->id]);
     DB::table('tasks')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'description' => 'do something else', 'due_date' => Carbon\Carbon::now()->toDateTimeString(), 'completed' => 0, 'project_id' => \App\Project::first()->id]);
 }