| Server IP : 3.138.164.131 / Your IP : 216.73.216.136 Web Server : Apache System : Linux ns1.techtime.me 4.18.0-147.8.1.el8.lve.1.x86_64 #1 SMP Mon Jun 29 09:55:57 EDT 2020 x86_64 User : injazaat ( 1471) PHP Version : 8.1.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/injazaat/public_html/app/Http/Controllers/ |
Upload File : |
<?php
namespace App\Http\Controllers;
use App\Models\Project;
use App\Models\Projectdetails;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Validator;
Use RealRashid\SweetAlert\Facades\Alert;
use File;
class ProjectdetailsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($id)
{
$data['id']=$id;
$data['project_details'] = Projectdetails::where('project_id',$id)->get();
return view('admin.project_details.index', $data);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create($id)
{
$data['id']=$id;
return view('admin.project_details.create',$data);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request,$id)
{
$validitor = Validator::make($request->all(), [
'title' => 'required|max:255',
'title_ar' => 'required|max:255',
'picture' => 'sometimes|image'
]);
if ($validitor->fails()) {
alert()->error('Opps...','There is some issue with input');
return Redirect::route('add-service-details',$id)->withErrors($validitor)->withInput();
}
$project_details = new Projectdetails();
if($request->hasFile('image')){
$image = $request->file('image');
$image_name = time().$image->getClientOriginalName();
$path = $request->file('image')->move('project_img', $image_name);
$project_details->picture = 'project_img/'.$image_name;
}
$project_details->title = $request->title;
$project_details->title_ar = $request->title_ar;
$project_details->priority = $request->priority;
$project_details->project_id = $id;
$project_details->save();
Alert::success('Success ', 'Project Details has been Created');
return Redirect::route('show-project-details',$id);
}
/**
* Display the specified resource.
*
* @param \App\Models\Projectdetails $projectdetails
* @return \Illuminate\Http\Response
*/
public function show(Projectdetails $projectdetails)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Projectdetails $projectdetails
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$data['project_details'] = Projectdetails::find($id);
$data['id'] = $id;
return view('/admin/project_details.update', $data);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Projectdetails $projectdetails
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$validitor = Validator::make($request->all(), [
'title' => 'required|max:255',
'title_ar' => 'required|max:255',
'picture' => 'sometimes|image'
]);
if ($validitor->fails()) {
alert()->error('Opps...','There is some issue with input');
return Redirect::route('add-service-details',$id)->withErrors($validitor)->withInput();
}
$project_details = Projectdetails::find($id);
if($request->hasFile('image')){
$image = $request->file('image');
$image_name = time().$image->getClientOriginalName();
$path = $request->file('image')->move('project_img', $image_name);
$project_details->picture = 'project_img/'.$image_name;
}
$project_details->title = $request->title;
$project_details->title_ar = $request->title_ar;
$project_details->priority = $request->priority;
$project_details->save();
Alert::success('Success ', 'Project Details has been Created');
return Redirect::route('show-project-details',$id);
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Projectdetails $projectdetails
* @return \Illuminate\Http\Response
*/
public function destroy(Projectdetails $projectdetails)
{
//
}
}