HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/qas.sports-crowd.com/app/Http/Controllers/BookcaseEmbedController.php
<?php

namespace App\Http\Controllers;

use App\BookcaseEmbed;
use Illuminate\Http\Request;
use DB;
use Datatables;

class BookcaseEmbedController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('bookcase_embed.bookcase');
    }

    public function indexAdd()
    {
        return view('bookcase_embed.addBookcase');
    }

    public function indexEdit($id)
    {

        $bookcase = BookcaseEmbed::find($id);

        return view('bookcase_embed.editBookcase')
            ->with('bookcase_embed', $bookcase);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create(Request $request)
    {
        $bookcase = new BookcaseEmbed();
        $bookcase->link = $request["link"];
        $bookcase->active = true;
        $bookcase->save();

        if ($bookcase) {
            return array('r' => true, 'd' => array('id' => $bookcase->id), 'm' => trans('messages.screen_bookcase_tag14'));
        } else {
            return array('r' => false, 'd' => null, 'm' => trans('messages.screen_bookcase_tag15'));
        }
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request)
    {
        $bookcase = BookcaseEmbed::find($request["id"]);
        $bookcase->link = $request["link"];
        $bookcase->update();

        if ($bookcase) {
            return array('r' => true, 'd' => array('id' => $bookcase->id), 'm' => trans('messages.screen_bookcase_tag16'));
        } else {
            return array('r' => false, 'd' => null, 'm' => trans('messages.screen_bookcase_tag17'));
        }
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }

    public function activateBookcase(Request $request)
    {
        $id = $request['id'];
        $state = $request['state'];

        $banner = BookcaseEmbed::find($id);
        $banner->active = $state;
        $banner->update();

        if ($banner) {
            return array('r' => true, 'd' => null, 'm' => trans('messages.screen_bookcase_tag18'));
        } else {
            return array('r' => false, 'd' => null, 'm' => trans('messages.screen_bookcase_tag19'));
        }
    }

    public function tableFilter()
    {
        $obj = $obj = DB::table('bookcase_embeds')
            ->select('bookcase_embeds.id', 'bookcase_embeds.link', 'bookcase_embeds.active');


        return Datatables::of($obj)
            ->addColumn('actions', function ($obj) {
                return '
               <i class="fa fa-pencil iconMini" onClick="clickEditBookcase(' . $obj->id . ')" data-id="' . $obj->id . '" data-toggle="tooltip" data-placement="bottom" title="Editar" style="cursor:pointer;"></i>
               <i class="fa fa-trash iconMini" onClick="clickDeleteBookcase(' . $obj->id . ')" data-id="' . $obj->id . '" data-toggle="tooltip" data-placement="bottom" title="Eliminar" style="cursor:pointer;"></i>
            ';
            })
            ->editColumn('active', function ($obj) {
                if ($obj->active == 0) {
                    return '<div class="switch"><label><div class="checkbox checbox-switch switch-success"> <label> No <input type="checkbox" onChange="chkBookcase(' . $obj->id . ')" data-id="' . $obj->id . '" id="Checkactive' . $obj->id . '" name="Checkactivo" /> <span></span>Si </label></div> </label> </div>';
                } else {
                    return '<div class="switch"><label> <div class="checkbox checbox-switch switch-success"> <label>   No <input type="checkbox" onChange="chkBookcase(' . $obj->id . ')" data-id="' . $obj->id . '" id="Checkactive' . $obj->id . '" name="Checkactivo" checked="" />
                        <span></span> Si </label> </div>  </label> </div>';
                }
            })
            ->rawColumns(['active', 'actions', 'image'])
            ->make(true);
    }

    public function delete(Request $request)
  {
    $bookcase = BookcaseEmbed::find($request['id']);
    $bookcase->delete();
    if ($bookcase) {
      return array('r' => true, 'd' => null, 'm' => trans('messages.screen_bookcase_tag20'));
    } else {
      return array('r' => false, 'd' => null, 'm' => trans('messages.screen_bookcase_tag21'));
    }
  }
}