use App\Http\Controllers\Admin\Base\QuizController;
use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel;
use Cubist\Util\Files\Files;
-use Cubist\Util\Zip;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\Image\Manipulations;
use App\Fields\User;
--- /dev/null
+<?php
+
+namespace App\Policies;
+
+use App\Models\FluidbookQuote;
+use App\Models\User;
+use Illuminate\Auth\Access\HandlesAuthorization;
+
+class FluidbookQuotePolicy
+{
+ use HandlesAuthorization;
+
+ /**
+ * Determine whether the user can view any models.
+ *
+ * @param User $user
+ * @return mixed
+ */
+ public function viewAny(User $user)
+ {
+ return $user->hasPermissionTo('fluidbook:quote:admin');
+ }
+
+ /**
+ * Determine whether the user can view the model.
+ *
+ * @param User $user
+ * @param FluidbookQuote $fluidbookQuote
+ * @return mixed
+ */
+ public function view(User $user, FluidbookQuote $fluidbookQuote)
+ {
+ if ($this->viewAny($user)) {
+ return true;
+ }
+ return $user->getKey() == $fluidbookQuote->reseller;
+ }
+
+ /**
+ * Determine whether the user can create models.
+ *
+ * @param User $user
+ * @return mixed
+ */
+ public function create(User $user)
+ {
+ return false;
+ }
+
+ /**
+ * Determine whether the user can update the model.
+ *
+ * @param User $user
+ * @param FluidbookQuote $fluidbookQuote
+ * @return mixed
+ */
+ public function update(User $user, FluidbookQuote $fluidbookQuote)
+ {
+ return $this->view($user, $fluidbookQuote);
+ }
+
+ /**
+ * Determine whether the user can delete the model.
+ *
+ * @param User $user
+ * @param FluidbookQuote $fluidbookQuote
+ * @return mixed
+ */
+ public function delete(User $user, FluidbookQuote $fluidbookQuote)
+ {
+ return false;
+ }
+
+ /**
+ * Determine whether the user can restore the model.
+ *
+ * @param User $user
+ * @param FluidbookQuote $fluidbookQuote
+ * @return mixed
+ */
+ public function restore(User $user, FluidbookQuote $fluidbookQuote)
+ {
+ return false;
+ }
+
+ /**
+ * Determine whether the user can permanently delete the model.
+ *
+ * @param User $user
+ * @param FluidbookQuote $fluidbookQuote
+ * @return mixed
+ */
+ public function forceDelete(User $user, FluidbookQuote $fluidbookQuote)
+ {
+ return false;
+ }
+}
namespace App\Policies;
-use App\Quiz;
-use App\User;
+use App\Models\Quiz;
+use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class QuizPolicy
/**
* Determine whether the user can view any quizzes.
*
- * @param \App\User $user
+ * @param User $user
* @return mixed
*/
public function viewAny(User $user)
/**
* Determine whether the user can view the quiz.
*
- * @param \App\User $user
- * @param \App\Quiz $quiz
+ * @param User $user
+ * @param Quiz $quiz
* @return mixed
*/
public function view(User $user, Quiz $quiz)
/**
* Determine whether the user can create quizzes.
*
- * @param \App\User $user
+ * @param User $user
* @return mixed
*/
public function create(User $user)
/**
* Determine whether the user can update the quiz.
*
- * @param \App\User $user
- * @param \App\Quiz $quiz
+ * @param User $user
+ * @param Quiz $quiz
* @return mixed
*/
public function update(User $user, Quiz $quiz)
/**
* Determine whether the user can delete the quiz.
*
- * @param \App\User $user
- * @param \App\Quiz $quiz
+ * @param User $user
+ * @param Quiz $quiz
* @return mixed
*/
public function delete(User $user, Quiz $quiz)
/**
* Determine whether the user can restore the quiz.
*
- * @param \App\User $user
- * @param \App\Quiz $quiz
+ * @param User $user
+ * @param Quiz $quiz
* @return mixed
*/
public function restore(User $user, Quiz $quiz)
/**
* Determine whether the user can permanently delete the quiz.
*
- * @param \App\User $user
- * @param \App\Quiz $quiz
+ * @param User $user
+ * @param Quiz $quiz
* @return mixed
*/
public function forceDelete(User $user, Quiz $quiz)
</li>
@endcanany
-@can('fluidbook:admin')
+@canany(['fluidbook:admin','fluidbook:quote'])
<li class='nav-item nav-dropdown open'><a class='nav-link nav-dropdown-toggle' href='#'><i
class="nav-icon la"><img src="/images/icons/icon-fluidbook.svg"/></i>Fluidbook</a>
<ul class='nav-dropdown-items'>
- <li class="nav-item"><a class="nav-link" href="{{ backpack_url('signature') }}"><i
- class="la la-signature nav-icon"></i> Signatures</a></li>
- <li class="nav-item"><a class="nav-link" href="{{ backpack_url('fluidbook-quote') }}"><i
- class="la la-wpforms nav-icon"></i> Demandes de devis</a></li>
+ @can('fluidbook:admin')
+ <li class="nav-item"><a class="nav-link" href="{{ backpack_url('signature') }}"><i
+ class="la la-signature nav-icon"></i> Signatures</a></li>
+ @endcan
+ @can('fluidbook:quote')
+ <li class="nav-item"><a class="nav-link" href="{{ backpack_url('fluidbook-quote') }}"><i
+ class="la la-wpforms nav-icon"></i> Demandes de devis</a></li>
+ @endcan
</ul>
</li>
-@endcan
+@endcanany
@can('toolbox:maintenance')