/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\ProjectRequest $request)
 {
     //
     $data = $request->except('_token');
     $project_id = Project::create($data)->id;
     if ($request->hasFile('project_file')) {
         $date = Carbon::now()->timestamp;
         $filename = trim($request->get('req')) . "_" . $date . '.' . $request->file('project_file')->getClientOriginalExtension();
         $path = base_path() . '/public/up/INIT/';
         $request->file('project_file')->move($path, $filename);
         $projectfile = new ProjectFile();
         $projectfile->project_id = $project_id;
         $projectfile->project_file = $path . $filename;
         $projectfile->step_id = 1;
         $projectfile->save();
     }
     return back();
 }
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $template = Project::findOrFail($this->template_id);
     foreach ($template->commands as $command) {
         $data = $command->toArray();
         $data['project_id'] = $this->project->id;
         Command::create($data);
     }
     foreach ($template->sharedFiles as $file) {
         $data = $file->toArray();
         $data['project_id'] = $this->project->id;
         SharedFile::create($data);
     }
     foreach ($template->projectFiles as $file) {
         $data = $file->toArray();
         $data['project_id'] = $this->project->id;
         ProjectFile::create($data);
     }
 }
Beispiel #3
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    if (Auth::check()) {
        return view('welcome');
    }
    return view('auth.login');
});
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
// Registration routes...
Route::post('auth/register', 'Auth\\AuthController@postRegister');
Route::group(['middleware' => 'auth'], function () {
    Route::resource('project', 'ProjectController');
    Route::get('download/{id}/{step_id}', function ($id, $step_id) {
        $filename = \App\ProjectFile::where('project_id', $id)->where('step_id', $step_id)->value('project_file');
        return response()->download($filename);
    });
});