Eshop-Laravel/app/Menu.php

36 lines
813 B
PHP
Raw Permalink Normal View History

2019-10-18 09:25:37 +00:00
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Session , DB;
class Menu extends Model
{
static public function save_new($data){
$menu = new self();
$menu ->link = $data['link'];
$menu ->mtitle = $data['title'];
$menu ->url = $data['url'];
$menu ->save();
Session::flash('sm' , 'Menu Has been saved');
}
static public function find_item($id){
$sql = 'SELECT * FROM menus m WHERE m.id = ?';
$item = DB::select($sql,[$id] );
return $item;
}
static public function update_item($data,$id){
$menu = self::find($id);
$menu ->link = $data['link'];
$menu ->mtitle = $data['title'];
$menu ->url = $data['url'];
$menu ->save();
Session::flash('sm' , 'Menu Has been Updated!');
}
}