本文整理汇总了PHP中Auth::admin方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::admin方法的具体用法?PHP Auth::admin怎么用?PHP Auth::admin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::admin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public function destroy($id)
{
Admin::where('id', '=', $id)->delete();
Activity::log(['contentId' => $id, 'user_id' => Auth::admin()->get()->id, 'contentType' => 'Administrador', 'action' => 'Delete ', 'description' => 'Eliminacion de un administrador', 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $id ? true : false]);
$output['success'] = 'deleted';
return Response::json($output, 200);
}
示例2: errors
public static function errors($code = 404, $title = 'Oops! You\'re lost.', $message = '')
{
$ajax = Request::ajax();
if ($code == 404) {
$title = 'Oops! You\'re lost.';
$message = 'We can not find the page you\'re looking for.';
if (!$ajax) {
$message .= '<br/><a href="' . URL . '/admin">Return home </a>';
}
} else {
if ($code == 403) {
$title = 'Oops! You are not allowed to go to this page.';
$message = 'Please check your permission.';
if (!$ajax) {
$message .= '<a href="' . URL . '/admin">
Return home </a>';
}
} else {
if (!$code || $code == 500) {
$code = 500;
if (empty($title)) {
$title = 'Internal Server Error';
}
if (empty($message)) {
$message = 'We got problems over here. Please try again later!';
}
}
}
}
if ($ajax) {
return Response::json(['error' => ['title' => $title, 'message' => $message]], $code);
}
return View::make('admin.errors.error')->with(['title' => $title, 'code' => $code, 'message' => $message, 'admin' => Auth::admin()->get(), 'sideMenu' => Menu::getCache(['sidebar' => true]), 'currentTheme' => Cookie::has('theme') ? Cookie::get('theme') : 'default']);
}
示例3: index
public function index()
{
$arrType = [];
$arrMenu = Menu::getCache(['active' => 0]);
if (!empty($arrMenu)) {
foreach ($arrMenu as $type => $html) {
if (strpos($type, '-') !== false) {
unset($arrMenu[$type]);
list($type, $subType) = explode('-', $type);
$arrMenu[$type][$subType] = '<ol class="dd-list">' . $html . '</ol>';
$arrType[] = $subType;
} else {
$arrMenu[$type] = '<ol class="dd-list">' . $html . '</ol>';
$arrType[] = $type;
}
}
arsort($arrMenu);
} else {
$arrMenu = [];
}
$arrParent = Menu::getCache(['parent' => true]);
$admin = Auth::admin()->get();
$permission = new Permission();
$arrPermission = ['frontend' => ['view' => $permission->can($admin, 'menusfrontend_view_all'), 'create' => $permission->can($admin, 'menusfrontend_create_all'), 'edit' => $permission->can($admin, 'menusfrontend_edit_all'), 'delete' => $permission->can($admin, 'menusfrontend_delete_all')], 'backend' => ['view' => $permission->can($admin, 'menusbackend_view_all'), 'create' => $permission->can($admin, 'menusbackend_create_all'), 'edit' => $permission->can($admin, 'menusbackend_edit_all'), 'delete' => $permission->can($admin, 'menusbackend_delete_all')]];
$this->layout->title = 'Menu';
$this->layout->content = View::make('admin.menus-all')->with(['arrMenu' => $arrMenu, 'arrParent' => $arrParent, 'arrType' => $arrType, 'arrPermission' => $arrPermission]);
}
示例4: __construct
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct(Registrar $registrar)
{
//$this->middleware('guest', ['except' => 'getLogout']);
$this->auth = Auth::admin();
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}
示例5: store
/**
* Store a newly created resource in storage.
* POST /articles
*
* @return Response
*/
public function store()
{
$rules = Article::$rules;
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
$messages = $validator->messages();
// return Response::json(['error' => $messages], 400);
}
$image = Input::file('file');
if (!$image) {
return Response::json(['error' => $messages], 400);
} else {
$admin = Auth::admin();
$article = new Article();
$article->admin_id = Auth::admin()->get()->id;
$article->title = Input::get('title');
$article->body = Input::get('body');
$article->category_id = Input::get('category_id');
$article->save();
$thumb = new Photo();
$filename = time() . '-' . $image->getClientOriginalName();
$destinationPath = public_path('thumbs/' . $filename);
$a = Image::make($image->getRealPath())->fit(1280, 720)->save($destinationPath, 50);
// SAVE TO DB
$thumb->image = 'thumbs/' . $filename;
$thumb->article_id = $article->id;
$thumb->save();
}
}
示例6: index
public function index()
{
if (!Input::has('page')) {
$pageNum = 1;
} else {
$pageNum = (int) Input::get('page');
}
$admin_id = Auth::admin()->get()->id;
$arrCategories = [];
$name = '';
$take = $this->take;
$skip = floor(($pageNum - 1) * $take);
$images = VIImage::select('id', 'name', 'short_name', 'description', 'keywords', 'artist', 'model', 'gender', 'age_from', 'age_to', 'number_people', DB::raw('(SELECT COUNT(*)
FROM notifications
WHERE notifications.item_id = images.id
AND notifications.item_type = "Image"
AND notifications.admin_id = ' . $admin_id . '
AND notifications.read = 0 ) as new'))->withType('main')->with('categories')->with('collections');
if (Input::has('categories')) {
$arrCategories = (array) Input::get('categories');
$images->whereHas('categories', function ($query) use($arrCategories) {
$query->whereIn('id', $arrCategories);
});
}
if (Input::has('name')) {
$name = Input::get('name');
$nameStr = '*' . $name . '*';
$images->search($nameStr);
}
$images = $images->take($take)->skip($skip)->orderBy('id', 'desc')->get();
$arrImages = [];
if (!$images->isempty()) {
$arrImages = $arrRemoveNew = [];
foreach ($images as $image) {
$image->path = URL . '/pic/large-thumb/' . $image->short_name . '-' . $image->id . '.jpg';
$image->dimension = $image->width . 'x' . $image['height'];
if ($image->new) {
$arrRemoveNew[] = $image->id;
}
$arrImages[$image->id] = $image;
foreach (['arrCategories' => ['name' => 'categories', 'id' => 'id'], 'arrCollections' => ['name' => 'collections', 'id' => 'id']] as $key => $value) {
$arr = [];
foreach ($image->{$value}['name'] as $v) {
$arr[] = $v[$value['id']];
}
$arrImages[$image->id][$key] = $arr;
}
unset($arr);
}
if (!empty($arrRemoveNew)) {
Notification::whereIn('item_id', $arrRemoveNew)->where('item_type', 'Image')->where('admin_id', $admin_id)->update(['read' => 1]);
}
}
if (Request::ajax()) {
return $arrImages;
}
$this->layout->title = 'Images';
$this->layout->content = View::make('admin.images-all')->with(['images' => $arrImages, 'pageNum' => $pageNum, 'categories' => Category::getSource(), 'name' => $name, 'arrCategories' => $arrCategories, 'collections' => Collection::getSource(), 'apiKey' => Configure::getApiKeys()]);
}
示例7: isSeo
public static function isSeo()
{
if (Auth::admin()->get()->role_id == SEO) {
return true;
} else {
return false;
}
}
示例8: isEditor
public static function isEditor()
{
if (Auth::admin()->get()->role_id == EDITOR) {
return true;
} else {
return false;
}
}
示例9: __construct
/**
* Instantiate a new SiteUserController instance.
*/
public function __construct()
{
$this->beforeFilter(function () {
if (!Auth::admin()) {
return Redirect::to('/');
}
});
}
示例10: hasPermission
function hasPermission($permissionName)
{
$admin = Auth::admin()->get();
$permission = Hlacos\LaraMvcms\Models\Permission::where('name', $permissionName)->first();
if ($admin && $permission) {
return $admin->hasPermission($permission);
}
return false;
}
示例11: __construct
public function __construct()
{
$this->data['setting'] = Setting::all()->first();
if (!isset($this->data['setting']) && count($this->data['setting']) == 0) {
die('Database not uploaded.Please Upload the database');
}
if (count($this->data['setting'])) {
}
$this->data['loggedAdmin'] = Auth::admin()->get();
$this->data['pending_applications'] = Attendance::where('application_status', '=', 'pending')->get();
}
示例12: destroy
public function destroy($id)
{
if (Request::ajax()) {
Donacion::destroy($id);
$output['success'] = 'deleted';
Activity::log(['contentId' => $id, 'contentType' => 'Donacion', 'user_id' => Auth::admin()->get()->id, 'action' => 'Update', 'description' => 'Eliminacion de Donacion ' . $id, 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $id ? true : false]);
return Response::json($output, 200);
} else {
throw new Exception('Wrong request');
}
}
示例13: index
public function index()
{
$min_date = '01/01/2015';
$max_date = date('m/d/Y');
$data = ['admin_id' => Auth::admin()->get()->id];
$arrData = [];
$arrData['notifications'] = ['users' => Notification::getNew('User', $data), 'images' => Notification::getNew('Image', $data), 'orders' => Notification::getNew('Order', $data)];
$arrData['date'] = ['min_date' => $min_date, 'max_date' => $max_date, 'current_date' => new DateTime(), 'start_date' => new DateTime('7 days ago')];
$this->layout->title = 'Dashboard';
$this->layout->content = View::make('admin.dashboard')->with($arrData);
}
示例14: postUnlock
public function postUnlock()
{
$rules = array('password' => 'required');
$v = Validator::make(Input::all(), $rules);
if ($v->fails()) {
return Redirect::back()->withErrors($v);
}
$data = array('email' => Session::get('email'), 'password' => Input::get('password'));
Auth::admin()->attempt($data);
if (Auth::admin()->check()) {
return Redirect::to('admin/dashboard');
}
return Redirect::back()->with('failure', 'Invalid Password');
}
示例15: getNew
public static function getNew($type, $data)
{
if (!isset($data['admin_id'])) {
$data['admin_id'] = Auth::admin()->get()->id;
}
if (isset($data['get_id'])) {
$users = self::select('item_id')->where('admin_id', $data['admin_id'])->where('read', 0)->where('item_type', $type)->get();
$count = $users->count();
$arrReturn = ['count' => $count, 'id' => []];
foreach ($users as $user) {
$arrReturn['id'][] = $user->item_id;
}
return $arrReturn;
}
return self::where('admin_id', $data['admin_id'])->where('read', 0)->where('item_type', $type)->count();
}