/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     foreach (Piece::all() as $piece) {
         $medium = Medium::find(rand(1, Medium::count() - 1));
         $piece->media()->attach($medium);
     }
 }
예제 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Medium::create(['name' => 'Acrylic']);
     Medium::create(['name' => 'Watercolor']);
     Medium::create(['name' => 'Clay/Ceramic']);
     Medium::create(['name' => 'Glass']);
 }
예제 #3
0
파일: MediaHelp.php 프로젝트: manogi/gfw-qm
 /**
  * sanitize E-Mail-Addrsses.
  *
  * @return void
  */
 public static function sizes($medium_id)
 {
     $sizes = ['width' => 100, 'height' => 100];
     $medium = Medium::find($medium_id);
     if ($medium) {
         $src = 'media/' . $medium->id . '/original/' . $medium->filename;
         $path = public_path($src);
         $img_sizes = getimagesize($path);
         $sizes = ['width' => $img_sizes[0], 'height' => $img_sizes[1]];
     }
     return $sizes;
 }
예제 #4
0
파일: EmailHelp.php 프로젝트: manogi/gfw-qm
 /**
  * sanitize E-Mail-Addrsses.
  *
  * @return void
  */
 public static function attachmentFromMedium($medium_id)
 {
     $attachment = [];
     $medium = Medium::find($medium_id);
     $src = 'media/' . $medium->id . '/newsletter/' . $medium->filename;
     $path = public_path($src);
     if (!is_file($path)) {
         $src = 'media/' . $medium->id . '/original/' . $medium->filename;
         $path = public_path($src);
     }
     if (is_file($path)) {
         $img_sizes = getimagesize($path);
         $rawdata = file_get_contents($path);
         $attachment = ['type' => 'image/' . $medium->extension, 'name' => 'img_att_' . $medium->id, 'content' => base64_encode($rawdata)];
     }
     return $attachment;
 }
예제 #5
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  */
 public function edit($id)
 {
     if (Gate::denies('admin')) {
         abort(403);
     }
     $out = ['form_route' => ['route' => ['release.update', $id], 'method' => 'PUT', 'class' => 'form-horizontal'], 'artist_credit' => []];
     $out['release'] = Release::findOrNew((int) $id);
     $out['medium_types'] = Medium::lists('name', 'id');
     $out['release_status'] = ReleaseStatus::lists('name', 'id');
     $out['release_type'] = ReleaseType::lists('name', 'id');
     $out['work_type'] = WorkType::all();
     $out['genre'] = Genre::orderBy('id')->lists('name', 'id');
     if (count(Request::old())) {
         $old = Request::old();
         if (isset($old['artist_credit']['id'])) {
             foreach ($old['artist_credit']['id'] as $n => $ac_id) {
                 $artist = Artist::where('id', $ac_id)->firstOrFail();
                 if (count($artist)) {
                     $out['artist_credit'][$n]['name'] = $artist->name;
                     $out['artist_credit'][$n]['work_type_id'] = $old['artist_credit']['work'][$n];
                     $out['artist_credit'][$n]['join_phrase'] = $old['artist_credit']['join'][$n];
                     $out['artist_credit'][$n]['artist_id'] = $old['artist_credit']['id'][$n];
                 }
             }
         }
     } else {
         $out['artist_credit'] = $out['release']->credit->credit_name;
     }
     $out['genres_selected'] = [];
     foreach ($out['release']->genres as $row) {
         $out['genres_selected'][] = $row->id;
     }
     return view('releases.form', $out);
 }
예제 #6
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit(Piece $piece)
 {
     $media = Medium::lists('name', 'id');
     return view('admin.pieces.edit', compact('piece', 'media'));
 }